[前][次][番号順一覧][スレッド一覧]

ruby-changes:40170

From: knu <ko1@a...>
Date: Sat, 24 Oct 2015 01:53:51 +0900 (JST)
Subject: [ruby-changes:40170] knu:r52251 (trunk): * NEWS: [DOC] In the new safe call syntax, arguments are evaluated

knu	2015-10-24 01:53:41 +0900 (Sat, 24 Oct 2015)

  New Revision: 52251

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52251

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/doc/syntax/calling_methods.rdoc
Index: doc/syntax/calling_methods.rdoc
===================================================================
--- doc/syntax/calling_methods.rdoc	(revision 52250)
+++ doc/syntax/calling_methods.rdoc	(revision 52251)
@@ -29,7 +29,7 @@ NoMethodError. https://github.com/ruby/ruby/blob/trunk/doc/syntax/calling_methods.rdoc#L29
 
 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
-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
 used due to the potential for confusion with <code>::</code> for namespaces.
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52250)
+++ ChangeLog	(revision 52251)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Oct 24 01:51:01 2015  Akinori MUSHA  <knu@i...>
+
+	* 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@r...>
 
 	* lib/forwardable (def_instance_delegator, def_single_delegator):
Index: NEWS
===================================================================
--- NEWS	(revision 52250)
+++ NEWS	(revision 52251)
@@ -22,10 +22,13 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L22
 
   * 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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]