From: Hal Fulton Date: 2004-05-27T07:08:46+09:00 Subject: Re: nil.id #=> 4 ?!?!?! John Platte wrote: > Subject line says it all: nil.id #=> 4 !!! > > $ ruby -v > ruby 1.8.1 (2003-12-25) [powerpc-darwin] > $ ruby -e "puts nil.id; puts false.id; puts true.id" > 4 > 0 > 2 > > This showed up as a bug in my code when finding records against nil *GOT > RESULTS*. I'll need to override NilClass#id. :-/ > > I can certainly understand rationales for nil.respond_to?(:id) -- > everything's an object, etc., etc. But I also might suggest that the id > of nil shouldn't be 4?! Shouldn't nil be able to be used as a > lightweight and/or primitive Null Object? Why are you testing the value of nil.id? You know nil is nil already. The ids are the way they are because the first two bits convey information. I suggest you just live with this. And I suggest that if you are checking the id of nil, your code is likely flawed in concept. Hal