From: Alex Young Date: 2012-03-29T22:39:23+09:00 Subject: [ruby-core:43856] Re: [ruby-trunk - Feature #5008] Equal rights for Hash (like Array, String, Integer, Float) On 29/03/12 14:28, Adam Prescott wrote: > On Thu, Mar 29, 2012 at 13:25, rosenfeld (Rodrigo Rosenfeld Rosas) > > 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