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

ruby-changes:62429

From: Espartaco <ko1@a...>
Date: Thu, 30 Jul 2020 18:34:37 +0900 (JST)
Subject: [ruby-changes:62429] cfbae7dae0 (master): [skip-ci] Clarification for dup vs clone docs

https://git.ruby-lang.org/ruby.git/commit/?id=cfbae7dae0

From cfbae7dae052180e5dde05a27948ae8d779eccab Mon Sep 17 00:00:00 2001
From: Espartaco Palma <esparta@g...>
Date: Sun, 7 Jun 2020 01:01:37 -0700
Subject: [skip-ci] Clarification for dup vs clone docs

Both clone & dup returns a new object when executed
on the documentation looks like they are returning the
same object cloned or dup'ed which is true for method
as extend, but not for the above mentioned.

diff --git a/object.c b/object.c
index b47635f..9fb1481 100644
--- a/object.c
+++ b/object.c
@@ -550,11 +550,11 @@ rb_obj_clone(VALUE obj) https://github.com/ruby/ruby/blob/trunk/object.c#L550
  *	s1.extend(Foo) #=> #<Klass:0x401b3a38>
  *	s1.foo #=> "foo"
  *
- *	s2 = s1.clone #=> #<Klass:0x401b3a38>
+ *	s2 = s1.clone #=> #<Klass:0x401be280>
  *	s2.foo #=> "foo"
  *
- *	s3 = s1.dup #=> #<Klass:0x401b3a38>
- *	s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401b3a38>
+ *	s3 = s1.dup #=> #<Klass:0x401c1084>
+ *	s3.foo #=> NoMethodError: undefined method `foo' for #<Klass:0x401c1084>
  *--
  * Equivalent to \c Object\#dup in Ruby
  *++
-- 
cgit v0.10.2


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

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