Arrays union intersection and difference

suggest change
x = [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]

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents