Get all the elements that two arrays have in common with the ampersand operator (
&).[ 1, 1, 3, 5 ] & [ 1, 2, 3 ] # => [1, 3]This is taken from the ‘Programming Ruby’ Book, where you can find out more.
-
k776 liked this
-
progfu liked this
-
jewlofthelotus liked this
-
ecleel liked this
-
porta reblogged this from rubyquicktips
-
rubyquicktips posted this