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

ruby-changes:47033

From: nobu <ko1@a...>
Date: Fri, 23 Jun 2017 09:29:55 +0900 (JST)
Subject: [ruby-changes:47033] nobu:r59147 (trunk): refinements.rdoc: [DOC] improved [Fix GH-1659]

nobu	2017-06-23 09:29:45 +0900 (Fri, 23 Jun 2017)

  New Revision: 59147

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

  Log:
    refinements.rdoc: [DOC] improved [Fix GH-1659]
    
    * doc/syntax/refinements.rdocrefinements.rdoc: grammatical
      correction and code highlighting improved
    
    * doc/syntax/refinements.rdocrefinements.rdoc: Fixnum replaced
      with Integer and Integer with Numeric
    
    Author:    Shiva Bhusal <shivabhusal@u...>

  Modified files:
    trunk/doc/syntax/refinements.rdoc
Index: doc/syntax/refinements.rdoc
===================================================================
--- doc/syntax/refinements.rdoc	(revision 59146)
+++ doc/syntax/refinements.rdoc	(revision 59147)
@@ -49,13 +49,13 @@ until the end of the current class or mo https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L49
 the current file if used at the top-level.
 
 You may activate refinements in a string passed to Kernel#eval. Refinements
-are active the end of the eval string.
+are active until the end of the eval string.
 
 Refinements are lexical in scope.  Refinements are only active within a scope
-after the call to using. Any code before the using statement will not have the
+after the call to +using+. Any code before the +using+ statement will not have the
 refinement activated.
 
-When control is transferred outside the scope the refinement is deactivated.
+When control is transferred outside the scope, the refinement is deactivated.
 This means that if you require or load a file or call a method that is defined
 outside the current scope the refinement will be deactivated:
 
@@ -80,7 +80,7 @@ outside the current scope the refinement https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L80
   x.foo       # prints "C#foo in M"
   call_foo(x) #=> raises NoMethodError
 
-If a method is defined in a scope where a refinement is active the refinement
+If a method is defined in a scope where a refinement is active, the refinement
 will be active when the method is called.  This example spans multiple files:
 
 c.rb:
@@ -159,8 +159,8 @@ In a class: https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L159
   end
   # not activated here
 
-Note that the refinements in M are not activated automatically if the class
-Foo is reopened later.
+Note that the refinements in +M+ are *not* activated automatically if the class
++Foo+ is reopened later.
 
 In eval:
 
@@ -180,9 +180,9 @@ When not evaluated: https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L180
   end
   # not activated here
 
-When defining multiple refinements in the same module, inside a refine block
-all refinements from the same module are active when a refined method is
-called:
+When defining multiple refinements in the same module inside multiple +refine+ blocks,
+all refinements from the same module are active when a refined method(any of the +.to_json+ method from Example below) is
+called for the first time:
 
   module ToJSON
     refine Integer do
@@ -225,12 +225,12 @@ If no method was found at any point this https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L225
 
 Note that methods in a subclass have priority over refinements in a
 superclass.  For example, if the method <code>/</code> is defined in a
-refinement for Integer <code>1 / 2</code> invokes the original Fixnum#/
-because Fixnum is a subclass of Integer and is searched before the refinements
-for the superclass Integer.
+refinement for Numeric <code>1 / 2</code> invokes the original Integer#/
+because Integer is a subclass of Numeric and is searched before the refinements
+for the superclass Numeric. Since the method <code>/</code> is also present in child +Integer+ therefore, the method lookup never went to the superclass.
 
-If a method +foo+ is defined on Integer in a refinement, <code>1.foo</code>
-invokes that method since +foo+ does not exist on Fixnum.
+However, if a method +foo+ is defined on Numeric in a refinement, <code>1.foo</code>
+invokes that method since +foo+ does not exist on Integer.
 
 == +super+
 

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

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