From: Daniel Schierbeck Date: 2005-11-17T23:47:20+09:00 Subject: Re: Object#to_b Austin Ziegler wrote: > I used to use "unless > var.nil?" but it is easier to say: > > if var and var.foo > > than: > > if (not var.nil?) and var.foo `if var and var.foo' would still work. If `var' is undefined (nil), its #to_b method will return false. So unless var is an object that overrides the #to_b method, your code will still work. I can see the problem with the performance Matz brought up, but this was more meant as a philosophical discussion (though I can see now that I was quite concrete.) It actually came in response to the whole "subclassing FalseClass and NilClass" discussion, where I believe the #to_b method would be more true to the idea of duck-typing. Cheers, Daniel