Method: Parse::CollectionProxy#&

Defined in:
lib/parse/model/associations/collection_proxy.rb

#&(other_ary) ⇒ Array

Set Intersection - Returns a new array containing unique elements common to the two arrays. The order is preserved from the original array.

It compares elements using their hash and eql? methods for efficiency. See Array#&

Examples:

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

Parameters:

Returns:

  • (Array)

    intersection array



186
187
188
# File 'lib/parse/model/associations/collection_proxy.rb', line 186

def &(other_ary)
  collection & [other_ary].flatten
end