On 29/03/12 14:28, Adam Prescott wrote: > On Thu, Mar 29, 2012 at 13:25, rosenfeld (Rodrigo Rosenfeld Rosas) > <rr.rosas / gmail.com <mailto:rr.rosas / gmail.com>> wrote: > > Or for convenience we could allow nil to respond to each, like in > Groovy: > > null.each {} // or eachWithIndex - doesn't throw an exception > > > Why go down the road of adding this to nil instead of just relying on ||? > > foo = some_method || {} > foo.each { ... } > > If some_method is controlled, it can be made to return foo || {} if it > really does make sense for it to always return something that client > code can always use as a hash. Would you argue that this is wrong and should be removed? 1.9.3p125 :001 > nil.to_a => [] If not, why not? The same argument you've just made about hashes applies here. -- Alex