-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
class X
def total_cost
99
end
alias_method :old_dup, :dup
def dup
c = self.old_dup
class << c
attr_reader :total_cost
public
def initialize_copy(orig)
puts "Inside initialize_copy"
@total_cost = orig.total_cost
end
end
c.initialize_copy(self)
return c
end
end
an_x = X.new
an_x.dup$ ruby /tmp/t.rb
Inside initialize_copy
$ jruby /tmp/t.rb
NoMethodError: private method `initialize_copy' called for #<X:0x300cd634>
dup at /tmp/t.rb:16
(root) at /tmp/t.rb:22
$ jruby -v
jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on Java HotSpot(TM) 64-Bit Server VM 1.7.0_03-b04 [linux-amd64]
Reactions are currently unavailable