small medium large xlarge

11 Jun 2010, 07:59
Ingo Gambin (3 posts)

realized that ruby 1.9.1 does not like your example

-:8:in eval': wrong argument type Proc (expected Binding) (TypeError) from -:8:in '

Does that mean that in ruby 1.9.1 a lambda does not (as it does in ruby 1.8.7) create a binding? Or is eval not anymore able to evaluate a binding from a lambda?

I am pretty new to ruby so please forgive me if my questions seem stupid… ;)

Thanks in advance and best regards,


11 Jun 2010, 15:19
Dave Thomas (366 posts)

I wasn’t away of the change.

It looks like 1.9 now requires that you explicitly ask for the binding of the proc as the second argument to eval

ruby-1.9.2-preview3 > def get
ruby-1.9.2-preview3 ?>  i = 99
ruby-1.9.2-preview3 ?>  lambda {}
ruby-1.9.2-preview3 ?>  end
 => nil 
ruby-1.9.2-preview3 > p = get
 => #<Proc:0x000001009e81e8@(irb):11 (lambda)> 
ruby-1.9.2-preview3 > eval("i", p.binding)
 => 99 
15 Jun 2010, 06:46
Ingo Gambin (3 posts)

Ahh, yes. That looks good and somehow makes sense.

As creating a block with shows the same behaviour, I think I’ll just stick to always using @.binding@ then, regardless the ruby version.

Thanks a lot and best regards,


You must be logged in to comment