From: "rogerdpack (Roger Pack)" Date: 2012-07-14T15:04:23+09:00 Subject: [ruby-core:46415] [ruby-trunk - Feature #1122] request for: Object#try Issue #1122 has been updated by rogerdpack (Roger Pack). File try.txt added Attaching presentation, contents: Feature #1122 [request for Object#try (guarded method invocation)] Today: >> if entry.at('description') && entry.at('description').inner_text or: >> if (description = entry.at('description') && description.inner_text Proposal: Object#&& method: if entry.at('description').&&.inner_text or alternate Proposal Object#andand or Object#present? or some other name: if entry.at('description').present?.inner_text Pros: easier to read, no variable allocation. Unknown cons. ---------------------------------------- Feature #1122: request for: Object#try https://bugs.ruby-lang.org/issues/1122#change-28036 Author: authorNari (Narihiro Nakamura) Status: Rejected Priority: Normal Assignee: authorNari (Narihiro Nakamura) Category: core Target version: 2.0.0 =begin Hi. Object#try is new feature of rails2.3. http://guides.rubyonrails.org/2_3_release_notes.html http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/try.rb http://ozmm.org/posts/try.html Matz said: "OK, good name is the last problem." Anyone has better name? thanks. --- Narihiro Nakamura =end -- http://bugs.ruby-lang.org/