From: Gunther Diemant Date: 2011-12-09T01:56:58+09:00 Subject: Re: Removing a multiple array layer Try prod = prod.product(ranges) without loop. 2011/12/8 Sébastien M. : > Hi, > > I'm trying to remove a array layer implied by multiple Array#product > > Here is the code > ---------------- > def calculate ranges >  prod = ranges.shift >  ranges.each { |r| prod = prod.product(r) } >  puts prod.to_s > end > --------------------------------------------- > Here is what i do get > ---------------------- > [ >  [[["a", "b"], ["e", "f"]], ["i", "j"]], >  [[["a", "b"], ["e", "f"]], ["k", "l"]], >  ... > ] > ------------------------------------------- > And there is what i wish > ------------------------ > [ >  [["a", "b"], ["e", "f"], ["i", "j"]], >  [["a", "b"], ["e", "f"], ["k", "l"]], >  ... > ] > > Probably a silly question, but it's driving me mad. > I tried flatten, prod = prod[0], using Array#permutation, ... > Can't find my way out..??? > > Thanks > > -- > Posted via http://www.ruby-forum.com/. >