From: Hal Fulton Date: 2004-11-12T10:17:15+09:00 Subject: Re: non-nil, etc. (was Re: true? & false?) trans. (T. Onoma) wrote: > On Thursday 11 November 2004 07:30 pm, Gavin Sinclair wrote: > | Smiley shmiley: > | > | require 'extensions/object' > | > | if a.notnil? > | ... > | elsif b.nonnil? > | ... > | end > > What's wrong with: > > if not a.nil? > ... > end Nothing, really. I'd ordinarily use that, especially in public. It's a minor bit of (my personal) psychology, really. I'd rather ask what something IS rather than what it ISN'T. In the same way, we could say and 'if not a' -- but there is something a little clearer about 'a.nil?' instead. It's (distantly) like the line of code I wrote which said: upload unless unchanged and people commented, Why wouldn't you say: upload if changed And I could really only say: Well, that's how I think. When I code an if, I usually code the "expected" or "normal" case as the first branch, and the rest as the "else" part. Similarly when I use unless, it's usually when a case is (expected to be) rare or exceptional. Because the file would "normally" be changed, the "unless" part was an exception to the rule. This is that kind of thing. It's all in my head. Hal