Mean L. wrote in post #1082704:

> "the UnboundMethod can only be bound to an object that is an instance of
> a subclass of the owner class"

I never wrote this! The word owner refers an object of the class and not
a class. To be exact my wording is:

>> 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.

Cancelling the double negation below is what I said originally when I
quoted the book 'Programming Ruby 1.9', page 715!

> "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:

Like I said, i wrote this originally, and this is the rule, spelled out
in 'Programming Ruby 1.9', page 715! How can it be wrong, if it is
Ruby's requirement?

BTW, the same requirement is expressed in the statement you are
ignoring:

  {{ Base.new.is_a?(sub_foo.owner) && Base != Sub.superclass }}

Following is this condition in the example  using your code snippet from
your first post in this thread:

  class Base; def foo; puts "in Base"; end; end
  class Sub < Base; end
  class A < Sub; end

  base_foo = Base.instance_method :foo
  sub_foo = Sub.instance_method :foo
  base_foo.bind(Base.new).call #=> "in Base"
  sub_foo.bind(A.new).call     #=> "in Base"

  sub_foo.bind(Base.new).call \
    if Base.new.is_a?(sub_foo.owner) && Base != Sub.superclass

Comment this condition above out and you'll get the error telling you
exactly what I am telling you namely:

  ./t-bind.rb:31:in `bind': bind argument must be an instance \
      of Sub (TypeError) from ./t-bind.rb:31:in `<main>'


Cheers, igor

-- 
Posted via http://www.ruby-forum.com/.