From: Ken Bloom Date: 2007-12-12T09:10:02+09:00 Subject: Re: opposite .nil? On Tue, 11 Dec 2007 15:03:53 -0500, Andrew Stone wrote: > Note: parts of this message were removed by the gateway to make it a > legal Usenet post. > >> 1) No such opposite-of-nil? method exists. If you want it, add it. >> >> > Thanks for actually answering my question. Much appreciated. > > 2) In the particular example above (which I realize is just an >> example) you could write that as: >> >> def should_this_by_done? >> am_I_sure? unless !my_object || my_object.var.nil? >> end >> >> But, of course, that just moves the negation. >> >> > Sure, I was just looking for a more readable construct. Thanks again > for your reply. def should_this_be_done? am_I_sure? && my_object && !my_object.var.nil? end Here's a more readable construct: def should_this_be_done? am_I_sure? and my_object and not my_object.var.nil? end You're not forced to program Ruby like it's C. --Ken -- Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/