From: "David A. Black" Date: 2005-08-08T01:50:54+09:00 Subject: Re: Adding yet another Array.new form Hi -- On Sun, 7 Aug 2005, Christian Neukirchen wrote: > Nikolai Weibull writes: > >> Lately I've been using the Kernel.returning method from Rails to write >> it as >> >> def a >> returning ary = [] do >> ... construct ary by adding elements to it ... >> end >> end >> [...] > > I'd rather vote in favor of including #returning to the Ruby core. > It is a very helpful method to DRY. It feels a bit side-effect-dependent-ish, as written. It might be nicer with a more traditional yield/block param syntax: returning [] do |ary| ... end That shows more of the separation between the fact that you're returning an array, and the fact that you're assigning the name ary to that array for use inside the block. David -- David A. Black dblack@wobblini.net