From: Robert Klemme Date: 2005-09-23T00:51:40+09:00 Subject: Re: Instantiating a subclass of NilClass. Trans wrote: > Robert Klemme wrote: >> Hm... I guess NilClass in Java lingo would be a final class, i.e., >> no inheritance allowed. >> >> Btw, why do you want to do that? I mean, you can create a class with >> nil-like behavior (apart from the boolean behavior I guess) without >> inheriting NilClass, can't you? > > Yea, but the boolean behavior is important. I'm using it in a > OpenStruct like class, so that: > > o = OpenStructLike.new > o.foo #=> null > o.foo.bar #=> null > > As it is: > > o.foo #=> nil > o.foo.bar #=> ERROR > Thanks, unfortunately w/o the boolean behavior it won't work > transparently. It's still not clear to me why you need that. Why can't you simply use nil? If we know the whole story we might be able to come up with a different solution. I mean, why do you need to be able to invoke methods on uninitialized members? I can remember that we had a similar discussion a while ago and your implementation of method_missing might lead to undetected errors. So I personally would not find this desirable. What makes you think differently here? Kind regards robert