I need to make intersection of n-arrays with millions of elements (database ID's). This code works perfect, but slow (with very big arrays). How can i improve it?
[[1,2,3,4],[2,4,6,8],[4,5,8]].inject([]){|c,v| c = v if c.size==0; c = c&v if c.size>0; c }