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

ruby-changes:50905

From: nobu <ko1@a...>
Date: Sat, 7 Apr 2018 22:03:41 +0900 (JST)
Subject: [ruby-changes:50905] nobu:r63112 (trunk): Remove outdated example from Numeric documentation

nobu	2018-04-07 22:03:35 +0900 (Sat, 07 Apr 2018)

  New Revision: 63112

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

  Log:
    Remove outdated example from Numeric documentation
    
    Since 2.5, Numeric instances can be cloned and duplicated.
    
    [Fix GH-1850]
    
    From: Miguel Landaeta <miguel@m...>

  Modified files:
    trunk/numeric.c
Index: numeric.c
===================================================================
--- numeric.c	(revision 63111)
+++ numeric.c	(revision 63112)
@@ -5277,10 +5277,11 @@ rb_int_s_isqrt(VALUE self, VALUE num) https://github.com/ruby/ruby/blob/trunk/numeric.c#L5277
  *   1.object_id == a.object_id   #=> true
  *
  * There can only ever be one instance of the integer +1+, for example. Ruby ensures this
- * by preventing instantiation and duplication.
+ * by preventing instantiation. If duplication is attempted, the same instance is returned.
  *
- *   Integer.new(1)   #=> NoMethodError: undefined method `new' for Integer:Class
- *   1.dup            #=> TypeError: can't dup Integer
+ *   Integer.new(1)                   #=> NoMethodError: undefined method `new' for Integer:Class
+ *   1.dup                            #=> 1
+ *   1.object_id == 1.dup.object_id   #=> true
  *
  * For this reason, Numeric should be used when defining other numeric classes.
  *

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

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