On Thu, Mar 29, 2012 at 13:25, rosenfeld (Rodrigo Rosenfeld Rosas) <
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.