E
Eli Bendersky
Hello all,
Some things are unclear to me about Method#to_proc. I understand the
following:
plus = 12.method("+")
p plus.call(13) # prints 25
newplus = plus.unbind.bind(20)
p newplus.call(13) # prints 33
Although the usefulness of this eludes me
However, this:
plus_proc = plus.to_proc
p plus_proc.call(10) # prints 10
Is unclear... How does it work ? What does it mean for a Proc to be
bound to an object ? Can someone provide an example where it is useful
?
Also, have the 'bind' and 'unbind' methods of Method / UnboundMethod
anything in common with Proc#binding or the Binding class ? Have
Proc#binding and the Binding class anything in common ? How about
Kernel#binding ?
Thanks,
Eli
Some things are unclear to me about Method#to_proc. I understand the
following:
plus = 12.method("+")
p plus.call(13) # prints 25
newplus = plus.unbind.bind(20)
p newplus.call(13) # prints 33
Although the usefulness of this eludes me
However, this:
plus_proc = plus.to_proc
p plus_proc.call(10) # prints 10
Is unclear... How does it work ? What does it mean for a Proc to be
bound to an object ? Can someone provide an example where it is useful
?
Also, have the 'bind' and 'unbind' methods of Method / UnboundMethod
anything in common with Proc#binding or the Binding class ? Have
Proc#binding and the Binding class anything in common ? How about
Kernel#binding ?
Thanks,
Eli