How does Ruby's "Method#unbind" and "UnboundMethod#bind" pair work, and what is a practical use case?
Correct! Well done.
Incorrect.
The correct answer is B) unbind detaches a Method object from its receiver, producing an UnboundMethod that can later be bound to a compatible object via bind, useful for transplanting methods between objects of compatible classes (e.g. in module composition or testing)
Correct Answer
unbind detaches a Method object from its receiver, producing an UnboundMethod that can later be bound to a compatible object via bind, useful for transplanting methods between objects of compatible classes (e.g. in module composition or testing)
UnboundMethod represents a method definition independent of any particular object; binding it to a new (compatible) receiver allows reusing method implementations across otherwise unrelated class hierarchies in advanced metaprogramming scenarios.