From: Trans Date: 2005-09-23T00:26:39+09:00 Subject: Re: Instantiating a subclass of NilClass. 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 > require 'singleton' > > class NullClass > include Singleton > > def inspect ; 'null' ; end > def nil?() true end > def method_missing(*args) ; self ; end > end > > module Kernel > def null > NullClass.instance > end > end Thanks, unfortunately w/o the boolean behavior it won't work transparently. T.