diff --git a/ChangeLog b/ChangeLog index 61a5092265..abded68d31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Oct 24 01:51:01 2015 Akinori MUSHA + + * NEWS: [DOC] In the new safe call syntax, arguments are evaluated + only if a call is made. + + * doc/syntax/calling_methods.rdoc: Fix a typo. + Sat Oct 24 00:38:34 2015 Shugo Maeda * lib/forwardable (def_instance_delegator, def_single_delegator): diff --git a/NEWS b/NEWS index 6be8737c4e..1433dee4d6 100644 --- a/NEWS +++ b/NEWS @@ -22,10 +22,13 @@ with all sufficient information, see the ChangeLog file. * new method call syntax, `object.?foo', method #foo is called on `object' if it is not nil. - this is similar to `try!' in Active Support, except for: + this is similar to `try!' in Active Support, except: * method name is syntactically required obj.try! {} # valid obj.? {} # syntax error + * arguments are evaluated only if a call is made: + obj.try!(:foo, bar()) # bar() is always evaluated + obj.?foo(bar()) # bar() is conditionally evaluated * attribute assignment is valid obj.?attr += 1 diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc index db0217cfef..99ec48af40 100644 --- a/doc/syntax/calling_methods.rdoc +++ b/doc/syntax/calling_methods.rdoc @@ -29,7 +29,7 @@ NoMethodError. You may use .? to designate a receiver, then +my_method+ is not invoked and the result is +nil+ when the receiver is +nil+. In that case, the -argument of +my_method+ are not evaluated. +arguments of +my_method+ are not evaluated. You may also use :: to designate a receiver, but this is rarely used due to the potential for confusion with :: for namespaces.