mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4daa1cf730
commit
1b5dce5a4e
3 changed files with 12 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Sat Oct 24 01:51:01 2015 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* 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 <shugo@ruby-lang.org>
|
Sat Oct 24 00:38:34 2015 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* lib/forwardable (def_instance_delegator, def_single_delegator):
|
* lib/forwardable (def_instance_delegator, def_single_delegator):
|
||||||
|
|
5
NEWS
5
NEWS
|
@ -22,10 +22,13 @@ with all sufficient information, see the ChangeLog file.
|
||||||
|
|
||||||
* new method call syntax, `object.?foo', method #foo is called on
|
* new method call syntax, `object.?foo', method #foo is called on
|
||||||
`object' if it is not nil.
|
`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
|
* method name is syntactically required
|
||||||
obj.try! {} # valid
|
obj.try! {} # valid
|
||||||
obj.? {} # syntax error
|
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
|
* attribute assignment is valid
|
||||||
obj.?attr += 1
|
obj.?attr += 1
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ NoMethodError.
|
||||||
|
|
||||||
You may use <code>.?</code> to designate a receiver, then +my_method+ is not
|
You may use <code>.?</code> to designate a receiver, then +my_method+ is not
|
||||||
invoked and the result is +nil+ when the receiver is +nil+. In that case, the
|
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 <code>::</code> to designate a receiver, but this is rarely
|
You may also use <code>::</code> to designate a receiver, but this is rarely
|
||||||
used due to the potential for confusion with <code>::</code> for namespaces.
|
used due to the potential for confusion with <code>::</code> for namespaces.
|
||||||
|
|
Loading…
Reference in a new issue