Project

General

Profile

Actions

Misc #12122

closed

Array Documentation (set intersection, union)

Added by slash_nick (Ryan Hosford) over 8 years ago. Updated over 8 years ago.

Status:
Closed
Assignee:
-
[ruby-core:74026]

Description

Set Intersection

  • Most know what intersection means, but saying the operation excludes duplicates could be misleading ([1] & [1], duplicates excluded, might mean a result of []).
  • Instead, saying intersection returns the unique elements common to both arrays is more concise and less ambiguous.

Set Union

  • The set union's documentation was incomplete in its describing preservation of order. Saying union preserves the order of the original array neglects the idea that the order of the elements in both arrays, as given, will be preserved.
  • Instead, saying set union preserves the order from the given arrays (and adding an example) fully demonstrates the idea.
  • Adds an example I think better demonstrates the preservation of order: [ "c", "d", "a" ] | [ "a", "b", "c" ] #=> [ "c", "d", "a", "b" ]

Open PR: https://github.com/ruby/ruby/pull/1273

Updated by hsbt (Hiroshi SHIBATA) over 8 years ago

  • Status changed from Open to Closed

Merged at r53958

Actions

Also available in: Atom PDF

Like0
Like0