I\'m trying to get a common element from a group of arrays in Ruby. Normally, you can use the & operator to compare two arrays, which returns elements
Behold the power of inject! ;)
inject
[[1,2,3],[1,3,5],[1,5,6]].inject(&:&) => [1]
As Jordan mentioned, if your version of Ruby lacks support for &-notation, just use
inject{|acc,elem| acc & elem}