From: Dave Burt Date: 2005-08-08T07:46:07+09:00 Subject: Re: cartesian product walter a kehowski wrote... > cartprod.rb:24: syntax error > (c ||= []) << ae,be > ^ > cartprod.rb:26: syntax error > cartprod.rb:132: syntax error class Array def cartprod(b) each do |ae| b.each do |be| if block_given? yield ae, be # <-- you can yield multiple objects else (c ||= []) << [ae, be] # <-- you need to put (ae, be) in a single # object (i.e. an array) to put in an array end end # <-- you had missed 2 closing braces (line 132 error) end c # <-- you want to return this if no block was given end end Cheers, Dave