From: ghazel@... Date: 2011-01-20T18:35:04+09:00 Subject: [ruby-core:34651] Re: Ruby operator equivalent to Groovy's "?." On Thu, Jan 20, 2011 at 1:13 AM, Jonas Pfenniger (zimbatm) wrote: > 2011/1/20 "Martin J. D��rst" : >> I have definitely had cases where such a feature would have been very handy. >> I don't think it's worth a special syntax, but having a dedicated method in >> Ruby core, even if the name is longer than two letters, would be very >> helpful. > > You need the syntax to cut trough the chain. Otherwise, all methods > would get called in any case, and you'd need to implement a fake > object to respond to these. Have you all seen try? https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/try.rb You can do: obj.try(:somePropertyName).try(:anotherGreatPropertyName).try(:anotherOne) -Greg