Skip to content

Instantly share code, notes, and snippets.

@jamesduncombe
Last active December 18, 2015 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesduncombe/5787616 to your computer and use it in GitHub Desktop.
Save jamesduncombe/5787616 to your computer and use it in GitHub Desktop.
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