From: Charles Oliver Nutter Date: 2008-08-24T11:14:22+09:00 Subject: Re: Why 'if 0' succeeds in Ruby M. Edward (Ed) Borasky wrote: > On Sun, 2008-08-24 at 02:31 +0900, Dave Bass wrote: >> But unfortunately Ruby regards both false and nil as not-true. For some >> reason, this is touted as a feature. >> >> False and nil are two quite different concepts and should not be >> conflated. > > Exactly! To make matters worse, Lisp "traditionally" treated nil as > false, but Scheme has "true", "false" and "nil" and nil is treated as > true in Scheme. > > So I don't have a problem with 0 not being false, but I do have a > problem with nil being false in Lisp and Ruby and true in Scheme. 0 is > 0, nil is nil, true is true and false is false and that is that! I tend to look at these things not from at the level of pedantic consistency-mongering but in terms of what would be lost if the concept were changed. * a ||= x would no longer work, since unassigned a (nil) would not evaluate to false causing x to be assigned. * @a ||= x would no longer work * a[n] ||= x would no longer work * a.b ||= x would no longer work "nil" being considered a boolean false seems absolutely natural to me, and it makes possible a large number of concepts in Ruby we'd really miss. - Charlie