From: "David A. Black" Date: 2009-02-11T07:42:02+09:00 Subject: [ruby-core:21972] Re: [Feature #1122] request for: Object#try Hi -- On Wed, 11 Feb 2009, Michal Babej wrote: > Hi, > > On Sunday 08 of February 2009 11:58:18 David A. Black wrote: >> It's a bit punctuation-heavy but I think it's preferable. Of course >> the whole thing leaves the question of how to handle ambiguous nils > You could slightly modify it to be > > foo.?bar(*args) : &block > > as a syntax sugar to: > > foo.respond?(:bar) ? foo.bar(args) : yield args > > Or something similar... though i'd probably look awful if you wanted to pass a > block to foo.bar :) Sorry but that's syntactic vinegar :-) David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!