From: Hal Fulton Date: 2005-08-08T02:22:09+09:00 Subject: Re: cartesian product Randy Kramer wrote: > On Sunday 07 August 2005 10:51 am, Martin DeMello wrote: > >>if block_given? >> yield ae, be >>else >> (c ||= []) << ae, be >>end > > > I'm sure you know what you're talking about, but I wonder how many others > will, even with comments. (Maybe I just need to go back to Pascal?) Haha... if it's this line you have trouble with (c ||= []) << ae, be it's not that hard. The ||= is a well-known idiom -- same as c = c || [] here. Basically "assign c this value, unless it is already non-nil." So then you have either an existing array or an empty one. Then you can append (<<) onto it. If it's the yield that bothers you, just study a bit more Ruby. Pascal was wonderful in 1980 -- unless you already knew something better -- but I'm content to let it go now. ;) Hal