Merge arrays
The Array
class defines the +
and -
methods. But also |
and &
for union and intersection.
No surprises with the +
method, which concatenates arrays, and -
, which subtracts. |
and &
will also remove duplicated elements. Order of arrays are preserved.
The ^
method has not been implemented. But if necessary, you can make the symmetrical difference by hand!
Links to Ruby documentation for Array#+
, Array#-
, Array#|
and Array#&
.