Project

General

Profile

Feature #1122 ยป try.txt

rogerdpack (Roger Pack), 07/14/2012 03:04 PM

 
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.
    (1-1/1)