0vit0q
Last Updated: February 25, 2016
·
3.448K
· devatotech

Ruby compare two arrays for matches

If you want a new array of matching results from two arrays:

[ 1, 1, 3, 5 ] & [ 1, 2, 3 ]                 #=> [ 1, 3 ]
[ 'a', 'b', 'b', 'z' ] & [ 'a', 'b', 'c' ]   #=> [ 'a', 'b' ]

Ruby Set Intersections