From: Christopher Dicely Date: 2008-08-25T07:19:28+09:00 Subject: Re: Why 'if 0' succeeds in Ruby On Sun, Aug 24, 2008 at 1:26 PM, matu wrote: > Dave Bass wrote: > >> False and nil are two quite different concepts and should not be >> conflated. > > I agree with you. I am also used to this. nil should never == true, and > neither be == false. Every comparison with nil should just fail. Every *comparison* with nil (except with itself) does fail. "unless foo" is not a comparison of foo with false, it is exactly equivalent to "if not foo". You seem to be recommending an SQL-style 3-value logic which is arguably useful in the context of SQL (though arguing that is a good way to start a fight among different factions of database idealists), but would, I think, have been a very bad choice for Ruby. Ruby instead uses a two valued logic in which every expression must be true or false in a boolean context. Given that, nil being false is the only sensible answer. If you had to have it any other way, the only even minimally acceptable way I can conceive would be nil being *unacceptable* in a boolean context (such that it would raise an exception if used in such a context), so you'd have to either do exception trapping or explicitly test for nils. While it would invalidate a lot of compact ruby idioms, you could argue that it would be cleaner in some respects, and it avoids the three-value logic problems.