fork download
  1. class B
  2. def self.foo
  3. "B.foo"
  4. end
  5.  
  6. def self.bar
  7. "B.bar"
  8. end
  9.  
  10. def bar
  11. "B#bar"
  12. end
  13. end
  14.  
  15. class C < B
  16. def self.bar
  17. "C.bar"
  18. end
  19.  
  20. def bar
  21. "C#bar"
  22. end
  23. end
  24.  
  25. p C.foo
  26. p C.bar
  27. p C.singleton_class.instance_method(:foo).bind(C).call #How come this doesn't error??
  28. p B.singleton_class.instance_method(:foo).bind(C).call
  29. # p C.new.foo => NoMethodError
  30. p C.new.bar
  31. p B.instance_method(:bar).bind(C.new).call
Success #stdin #stdout 0.01s 6244KB
stdin
Standard input is empty
stdout
"B.foo"
"C.bar"
"B.foo"
"B.foo"
"C#bar"
"B#bar"