Method: Array#intersect

Defined in:
lib/webget_ruby_ramp/array.rb

#intersectObject

Return the intersection of the array’s items. In typical usage, each item is an array.

Examples

arr=[[1,2,3,4],[3,4,5,6]]
arr.intersect
=> [3,4]

Examples with proc

arr.map(&:foo).intersect
=> foos that are in all of the array items

Example with nil

[].intersect => []


220
221
222
# File 'lib/webget_ruby_ramp/array.rb', line 220

def intersect
  inject{|inj,item| inj & item.to_a } || []
end