From: "Mean L." Date: 2012-11-04T12:06:43+09:00 Subject: Re: why does UnboundMethod need to remember the class it was retrieved from (not merely owner)? Igor Pirnovar wrote in post #1082696: > Mean L. wrote in post #1082692: > >> "why does UnboundMethod need to remember the class it was retrieved >> from (not merely owner)?" > > Because, the UnboundMethod can not be bound to an object that is not > instantiated as subclass of the class of the owner of the unbound > method. That is the requirement if you wish to bound it, period! I thought you at least understood the rule as it is, since you kept referring to it over and over. Let's examine what you posted: "can not be bound to an object that is not" -- cancelling the double negative gives us: "the UnboundMethod can only be bound to an object that is an instance of a subclass of the owner class" This is false on two separate counts: 1. It's not the owner that matters, but the class via which you retrieve the method (the one you call instance_method on), they are not the same. class Base; def foo; end end class Sub < Base; end class SubSub < Sub; end base_foo = Base.instance_method :foo sub_foo = Sub.instance_method :foo sub_sub_foo = SubSub.instance_method :foo. sub_sub_foo.bind(Sub.new).call In the above example, the owner of sub_sub_foo (sub_sub_foo.owner) is Base, Sub.new is an instance of Sub which is a subclass of Base, which satisfies your misconception/misstatement of the current rule. 2. even if we replace in you misstated rule, "owner" by "class on which instance_method was called to retrieve the method", it is still wrong because it refers to subclass, instead of subclass or same class. -- Posted via http://www.ruby-forum.com/.