[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Dup does not duplicate singleton methods

Mystifier

1/30/2005 12:53:00 PM

irb(main):001:0> a = Object.new
=> #<Object:0x2ae06d8>
irb(main):002:0> def a.p
irb(main):003:1> print "in a.p"
irb(main):004:1> end
=> nil
irb(main):005:0> a.p
in a.p=> nil
irb(main):006:0> b = a.dup
=> #<Object:0x2ad8668>
irb(main):007:0> b.p
NoMethodError: private method `p' called for #<Object:0x2ad8668>
from (irb):7
irb(main):008:0>

Duplication of singleton methods is not desirable?

Mystifier
1 Answer

ts

1/30/2005 12:57:00 PM

0

>>>>> "M" == Mystifier <mystifier@users.berlios.de> writes:

use #clone

M> irb(main):006:0> b = a.dup

b = a.clone


Guy Decoux