From: listrecv@... Date: 2005-11-14T07:57:15+09:00 Subject: Subclassing NilClass I'd like to subclass NilClass, creating a NullCase, implementing in Ruby a simple example of Martin Fowler's "SpecialCase" pattern ( http://patternshare.org/default.aspx/Home.MF.SpecialCase ) I'd like to subclass NilClass, so that the object returns false (and nil? returns true). But, I'd like to override method_missing so that it returns the an instance of NullCase - not an exception, and not a regular nil. I had trouble subclassing NilClass - there's no new method - how do I do this? Basically, usage would be like def a_method ... if condition x else NULL_CASE end end Later, you could do: a = o.a_method a.address.zip #--> No errors, just nil's instead of if a && a.address && a.address.zip a.address.zip else nil end Please cc all responses to me at listrecv at gmail, thanks!