From: Axel Etzold Date: 2007-10-15T04:52:00+09:00 Subject: Re: nil.to_i returning zero > What does nil.to_i return? Zero. And I wonder why. How can nil be > interpreted as a number. It's beyond me. > > Anyone care to explain it to me? Dear Gerardo, without claiming any particular authority, to me, this definition of what nil.to_i should return doesn't violate the principle of least surprise so cherished by Ruby coders - if you have nil dollars money, that's 0 dollars -- think of the balance of somebody who hasn't opened an account at "Ruby Deposit Bank" yet -- but if you wanted nil.to_i to raise an exception, because the "Ruby-Using Logicians Club" might be unhappy with such elliptic thinking, I might find that reasonable also. Maybe one has to distinguish between 0 and 1 on the one hand and false and true on the other, when coding Ruby, right from the start, to avoid any confusion. Best regards, Axel -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal f�r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer