Project

General

Profile

ActionsLike0

Feature #14097

closed

Add union and difference to Array

Added by ana06 (Ana Maria Martinez Gomez) almost 8 years ago. Updated almost 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:83721]

Description

Currently there is a concat method in ruby which does the same as +, but modifying the object. We could introduce a union and difference methods, which would be the equivalent for the | and - operators. This operators are normally less used due to lack of readability and expressivity. You end seeing thinks like:

array.concat(array2).uniq!

just because it is more readable. When it could be written like:

array |= array2

But, as this is not clear for some people, the new method will solve this problem:

array.union(array2)

And now this is clean and readable, as everybody expect from Ruby, the language focused on simplicity and productivity. ;)

Can I send a PR? :)


Related issues 1 (0 open1 closed)

Related to Ruby - Feature #14105: Introduce xor as alias for Set#^Feedbackknu (Akinori MUSHA)Actions
#14

Updated by ana06 (Ana Maria Martinez Gomez) over 7 years ago

  • Tracker changed from Bug to Feature
  • Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN)
#15

Updated by matz (Yukihiro Matsumoto) about 7 years ago

Updated by mame (Yusuke Endoh) almost 7 years ago

  • Status changed from Open to Assigned
  • Assignee set to matz (Yukihiro Matsumoto)
#30

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago

  • Status changed from Assigned to Closed
ActionsLike0

Also available in: Atom PDF