On 03/26/2013 11:19 AM, Joel VanderWerf wrote:
> On 03/25/2013 11:33 PM, Love U Ruby wrote:
>>  From the link -> http://www.ruby-doc.org/core-2.0/Binding.html
>>
>> Objects of class Binding encapsulate the execution context at some
>> particular place in the code and retain this context for future use. The
>> variables, ***methods, value of self, and possibly an iterator block
>> that can be accessed in this context are all retained***. Binding
>> objects can be created using Kernel#binding, and **are made available to
>> the callback of Kernel#set_trace_func**.
>
> Here's an example of getting the iterator block from the binding, but
> there is something puzzling:
>
> def foo; binding; end
> bi = foo {|x| p(x+1)}
>
> bi.eval "yield 2"       # ==> 3
> eval "yield 2", binding # ==> LocalJumpError

Oops. That was my mistake. The last line should be

eval "yield 2", bi       # ==> 3

It doesn't make a difference (as far as this example goes) whether you 
call Kernel#eval with a binding, or call Binding#eval.