Luke Graham wrote:
> On 5/6/05, John Carter <john.carter / tait.co.nz> wrote:
> 
>>I expect if this is accepted to see a bunch of knock on RCR's, namely
>>  nil+n == n
>>  nil * 7 == 0
>>-nil == 0
>>
>>We already have
>>  nil.to_s == ""
>>  nil.to_i == 0
>>  nil.to_f == 0.0
> 
> 
> This would be a big change to behaviour and a lot of existing programs
> could have problems with it. Because integers already have a to_i(),
> its possible to do this...
> 
> x.to_i + 3
> 
> and have it do what you want.

I'll comment also.

First of all, I sympathize on some level with this RCR. It has
been thought of before, by me and others.

In fact, I *think* that this was Ruby's default behavior once upon
a time; and I think it was changed for a good reason(s) I don't recall.

In other words, I think it falls under the category of "things that
were already in and have been taken out" (like Object#to_a, and like
the 'end' suffixes -- end if, end while, etc., which were taken out
when modifiers like 'x if y' were added).

FWIW, if x has a to_int, even this should work:

   y = 3 + x

although

   y = x + 3

wouldn't. But that is neither here nor there. And if something is
neither here nor there, where is it??


Hal