From: "David A. Black" Date: 2005-08-12T07:22:19+09:00 Subject: Re: NEWBIE QUESTION: pattern with nil Hi -- On Thu, 11 Aug 2005, Austin Ziegler wrote: > The problem, as others have stated, is that adding #empty? to > NilClass implies a containment. I'd have as big a problem if we > added #empty? to Fixnum so that 0 returned true and everything else > returned false. (Indeed, would that be correct? Would -3.empty? be > true or false?) I'd say it's undefined, or just meaningless. One could say that -3 "contains" three -1's... but I don't find that compelling. It could be said, equally (and equally wrongly, in my view), to "contain" a 5 and a -8. I don't consider something a container unless there's some meaning to the concept of inserting, removing, counting, iterating over elements. Even in the case of, say, a frozen array, there's still a meaning to the concept of altering the collection. You can't remove a 1 from 3. You can subtract 1 from 3, but that doesn't change 3. If it were otherwise, then the expression "3 - 1" would turn 3 into 2, which would cause lots of problems :-) I would say that propagating the notion of emptiness to non-collections definitely isn't the way to address nil-related issues. David -- David A. Black dblack@wobblini.net