From: Joel VanderWerf Date: 2004-11-12T08:23:04+09:00 Subject: Re: non-nil, etc. (was Re: true? & false?) Hal Fulton wrote: > class Array > def null? > ! empty? > end > end > > class String > def null? > ! empty? > end > end > > class Hash > def null? > ! empty? > end > end > > class Fixnum > def null? > self == 0 > end > end > > class File > def null? # now a little fun > size == 0 > end > end > > # And now even more fun > > class Nil > def null? > true > end > def nnil? # for symmetry > false > end > end > > # And the most fun of all, our beloved nnull? > > class Object > def null > false # until overridden > end > def nnull? > ! null? # inherited by everyone > end > end Why not just define #empty? for Fixum, File, NilClass, and Object, and then define nonempty? instead of (argh, can't... make... self... type... this...) nnull? ? The possibility of confusion between nil and null is too great (for me at least).