Skip to content

Instantly share code, notes, and snippets.

@hadrienblanc
Created July 22, 2020 15:07
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 hadrienblanc/1ae703653c525a6458fcef54fd921409 to your computer and use it in GitHub Desktop.
Save hadrienblanc/1ae703653c525a6458fcef54fd921409 to your computer and use it in GitHub Desktop.
x = [1, 1, 2, 4]
y = [1, 2, 2, 2]
# intersection
x & y # => [1, 2]
# union
x | y # => [1, 2, 4]
# difference
x - y # => [4]
@hadrienblanc
Copy link
Author

- Difference : Returns a new array that is a copy of the first array with any items that also appear in second array removed.
& Intersection : Creates a new array from two existing arrays containing only elements that are common to both arrays. Duplicates are removed.
| Union : Concatenates two arrays. Duplicates are removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment