From: Xavier Noria Date: 2007-08-18T22:14:01+09:00 Subject: Re: Emulating a Groovy feature? On Aug 18, 2007, at 2:55 PM, Arlen Christian Mart Cuss wrote: >> Sure, NilClass can be reopened just fine: >> >> class NilClass >> def method_missing(name, *args) >> nil >> end >> end >> >> nil.invoices.find(5) # -> nil > > > The only problem I can see here is that it's not quite optional. Yeah, that's the basic technique. You could use some naming convention as in Groovy as well (which you would check in the body of method_missing), or perhaps wrap the activation of that catchall in a block like this: with_safe_navigation do regular code end Once you can reopen NilClass like that I think there are ways to emulate that feature. -- fxn