From: Dave Burt Date: 2007-08-18T21:54:58+09:00 Subject: Re: Emulating a Groovy feature? John Wells wrote: > Guys, > > There's something called Safe Navigation in Groovy (http://groovy.codehaus.org/Statements#Statements-Safenavigation) that I find very appealing. > > So, Groovy will allow you to safely walk an object graph, even if that graph has nulls in it (the walk will short circuit): > > def foo = null > def bar = foo?.something?.myMethod() > assert bar == null > > Is there an easy way to hack an equivalent out in Ruby? irb(main):001:0> def nil.method_missing(*_) end => nil irb(main):002:0> nil.a.b.c => nil Cheers, Dave