From: Roger Pack Date: 2009-02-08T13:40:01+09:00 Subject: [ruby-core:21925] Re: [Feature #1122] request for: Object#try >>> Anyone has better name? For me try's name is good but not perfect. There are a few more options described at [1]. if_not_nil is one. andand is one. I'd probably prefer .try.method(args) to .try(:method, args) since it reads and codes more like a normal method call. I am assuming that try should protect against calling method on nil, not protect against calling methods that don't exist as instance_methods? That would make sense as it would allow for method_missing to define new methods on classes, etc. I suppose you could do both as separate methods, or have .try.method(args) do one thing and .try(:method, args) do another. One thing I "wish" were that you could do nilorstring.try.a.b.c.d # that allowed sub methods. re: >foo.?bar(baz) >as a syntax sugar to: > foo.respond?(:bar) ? foo.bar(baz) : nil One suggestion to a ruby quiz was the method name "_?" [2] Maybe foo.?.bar(baz) could mean foo.try.bar(baz)? Thanks for your work. -=r [1] http://weblog.raganwald.com/2008/01/objectandand-objectme-in-ruby.html [2] http://hobocentral.net/blog/2007/08/25/quiz/