Method: Array#%

Defined in:
lib/sc-core-ext/array.rb

#%(arr) ⇒ Object

Modulus operator: returns an array consisting only of those elements that are shared by both this array and the arr object. If arr is not an array, then only elements equal to arr itself are returned.

Examples:

[1, 2, 3] % [1, 2]   # => [1, 2]
[1, 2, 3] % 2        # => [2]


20
21
22
# File 'lib/sc-core-ext/array.rb', line 20

def %(arr)
  select { |i| arr.kind_of?(Array) ? arr.include?(i) : arr == i }
end