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

ruby-changes:26849

From: drbrain <ko1@a...>
Date: Wed, 23 Jan 2013 10:35:33 +0900 (JST)
Subject: [ruby-changes:26849] drbrain:r38901 (trunk): * doc/syntax/assignment.rdoc (Local Variables and Methods): Fixed

drbrain	2013-01-23 10:35:16 +0900 (Wed, 23 Jan 2013)

  New Revision: 38901

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

  Log:
    * doc/syntax/assignment.rdoc (Local Variables and Methods):  Fixed
      example showing caching of a method's results into a local variable.
      Added not about using an explicit receiver to call a method that
      matches a local variable.  Suggested by markov_twain on twitter.

  Modified files:
    trunk/ChangeLog
    trunk/doc/syntax/assignment.rdoc

Index: doc/syntax/assignment.rdoc
===================================================================
--- doc/syntax/assignment.rdoc	(revision 38900)
+++ doc/syntax/assignment.rdoc	(revision 38901)
@@ -86,11 +86,15 @@ code, for example: https://github.com/ruby/ruby/blob/trunk/doc/syntax/assignment.rdoc#L86
     42 # pretend this takes a long time
   end
 
-  big_calculation = big_calculation
+  big_calculation = big_calculation()
 
 Now any reference to +big_calculation+ is considered a local variable and will
 be cached.  To call the method, use <code>self.big_calculation</code>.
 
+You can force a method call by using empty argument parentheses as shown above
+or by using an explicit receiver like <code>self.</code>.  Using an explicit
+receiver may raise a NameError if the method's visibility is not public.
+
 Another commonly confusing case is when using a modifier +if+:
 
   p a if a = 0.zero?
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38900)
+++ ChangeLog	(revision 38901)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jan 23 10:34:47 2013  Eric Hodel  <drbrain@s...>
+
+	* doc/syntax/assignment.rdoc (Local Variables and Methods):  Fixed
+	  example showing caching of a method's results into a local variable.
+	  Added not about using an explicit receiver to call a method that
+	  matches a local variable.  Suggested by markov_twain on twitter.
+
 Wed Jan 23 10:20:08 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/README:  Fixed typo.  Patch by Pradeep Sahoo.

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

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