--e89a8fb1f476b2cabb04bc61b1a5
Content-Type: text/plain; charset=UTF-8

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  ome_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.

--e89a8fb1f476b2cabb04bc61b1a5
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div class="gmail_quote">On Thu, Mar 29, 2012 at 13:25, rosenfeld (Rodrigo Rosenfeld Rosas) <span dir="ltr">&lt;rr.rosas / gmail.com&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div id=":u0">Or for convenience we could allow nil to respond to each, like in Groovy:<br>
<br>
null.each {} // or eachWithIndex - doesn&#39;t throw an exception<br>
<div class="im"></div></div></blockquote></div><br><div>Why go down the road of adding this to nil instead of just relying on ||?</div><div><br></div><div>foo = some_method || {}</div><div>foo.each { ... }</div><div><br>

</div><div>If some_method is controlled, it can be made to return foo || {}f it really does make sense for it to always return something that clientode can always use as a hash.</div>

--e89a8fb1f476b2cabb04bc61b1a5--