Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby's array operators - Intersection, Union and Difference
# Ruby's Array operators
a = 1,2,3,4
b = 2,3,4,5
# Intersection
a & b # => [2, 3, 4]
# Union
a | b # => [1, 2, 3, 4, 5]
# Difference
a - b # => [1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment