From: Ron Jeffries Date: 2002-02-27T08:45:27+09:00 Subject: Re: fiddly little array manipulation question On 26 Feb 2002 22:58:43 GMT, Phil Mitchell wrote: >Is there a nicer way to take the intersection of an array of arrays, other >than: > >intersection = arrOfArrays[0] >for i in 1...arrOfArrays.length > intersection &= arrOfArrays[i] >end > >Am I missing some rubyism? Well, if you have inject defined, it's semi nice ... arys = [ [1, 2], [2, 3], [2, 4] ] class Array def inject (n) each { | value | n = yield(n, value) } n end end p arys.inject(arys[0]) { | int, each | int & each } Let's see what other folks offer ... Ronald E Jeffries http://www.XProgramming.com http://www.objectmentor.com I'm giving the best advice I have. You get to decide whether it's true for you.