fork download
  1. require 'delegate'
  2.  
  3. a = Object.new
  4. def a.f
  5. p 1
  6. end
  7.  
  8. b = Object.new
  9. def b.f
  10. p 2
  11. end
  12. c = SimpleDelegator.new( a )
  13. c.f
  14.  
  15. p c.__getobj__
  16. c.__setobj__ SimpleDelegator.new( b )
  17.  
  18. c.f
Success #stdin #stdout 0.01s 4848KB
stdin
Standard input is empty
stdout
1
#<Object:0x89451a8>
2