From: Harry Kakueki Date: 2011-12-26T00:05:39+09:00 Subject: Re: How to Combo On Sun, Dec 25, 2011 at 10:27 PM, Intransition wrote: > Easiest implementation of "some_method" in Ruby? > >      a = %w|a b| >      b = %w|a x| >      c = %w|x y| > >   some_method(a,b,c) > >   #=> > >    [ ["a", "a", "x"] >      ["a", "a", "y"] >      ["a", "x", "x"] >      ["a", "x", "y"] >      ["b", "a", "x"] >      ["b", "a", "y"] >      ["b", "x", "x"] >      ["b", "x", "y"] ] > > Order doesn't really matter. > This seems to do it. I don't have time now to try something better. Hope it helps. def some_method(a,b,c) [].tap{|w| a.each{|x| b.each{|y| c.each{|z| w << [x,y,z]}}}} end Harry