Arrays union intersection and difference
suggest changex = [5, 5, 1, 3]
y = [5, 2, 4, 3]
Union (|) contains elements from both arrays, with duplicates removed:
x | y
# => [5, 1, 3, 2, 4]
Intersection (&) contains elements that are present in both the first and the second array:
x & y
# => [5, 3]
Difference (-) contains elements that are present in the first array and not in the second:
x - y
# => [1]
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents