I am trying to find the intersection values between multiple arrays.
for example
code1 = [1,2,3] code2 = [2,3,4] code3 = [0,2,6]
So the
If you want a simpler way to do this with an array of arrays of unknown length, you can use inject.
> arrays = [code1,code2,code3] > arrays.inject(:&) # Ruby 1.9 shorthand => [2] > arrays.inject{|codes,x| codes & x } # Full syntax works with 1.8 and 1.9 => [2]