From: Martin DeMello Date: 2003-08-10T21:34:25+09:00 Subject: Re: Ruby and OOP-design (question of an old "procedural person" ;) dblack@superlink.net wrote: >> Yes if there's a specific documented and relied-on non-'true' true >> value. Not sure why I feel so prescriptive about this issue, but I find >> the whole thing very nonRubyish in the way it tries to pack two pieces > ^^^^^^^^^^ > (You mean non_Rubyish, of course :-) of course :) or even non_rubyish >> of information into a single primitive value. > > But isn't that true of all values in Ruby? Meaning, they all pack > boolean information intor themselves along with whatever else they > are. Not really - the boolean information usually acts as an existence test for the value. Here, by the semantics of nonzero?, the value *is* a boolean, so packing another value in for the sake of convenience feels wrong. IMO, this would be better in a 'nonzero' method (as opposed to 'nonzero?'), reading 'a.nonzero?' as 'is a nonzero?' and 'a.nonzero' as 'return the nonzero part of a' (by analogy with, say, Complex#im). Then if a is zero, the nonzero part of a could safely be said to be nil, and in a boolean context it'd be a proper existence test, and I at least would be happy :) martin