From: Martin DeMello Date: 2003-08-10T14:33:40+09:00 Subject: Re: Ruby and OOP-design (question of an old "procedural person" ;) Hal E. Fulton wrote: > >> Well and good, but they don't document the fact that the return value >> can be used as anything other than a boolean. Duck typing or no, I find >> it conceptually messy to have a method called nonzero? return self >> rather than true - compare nil? and zero?. Using the value of self feels >> like relying on an undocumented side effect. > > But as long as it isn't false or nil, it *is* true in effect. > And it's far from undocumented. I just said it *felt* like using an undocumented side effect, since it embraces-and-extends what I've been thinking of as the implicit contract of a ? method. > Yet in a way I sympathize... where I *would* feel funny is if > I made use of the numeric value returned rather than just > checking its truth... but I could probably get over even that. And likewise it feels funny when I see it in someone else's code. It may be useful, but so are a lot of other things that didn't make it into ruby because the semantics conflicted with the name. martin