From: "trans. (T. Onoma)" Date: 2004-10-05T03:00:29+09:00 Subject: Re: Kernel#eval taking a block On Monday 04 October 2004 11:11 am, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Kernel#eval taking a block" > > on Mon, 4 Oct 2004 23:23:22 +0900, "trans. (T. Onoma)" writes: > |Back to the original question: why Kernel#eval can't take a block? > > Because it's useless, for my eyes at least. What do you want to > accomplish by eval with a block? How to get locals into evaluation? class T def initialize @x = 1 end attr_reader :x def get_binding cool = "matz" return binding() end end t = T.new tb = t.get_binding eval "cool", tb #=> "matz" a = proc {|c| c.upcase} eval "cool = a.call(cool)", tb NameError: undefined local variable or method `a' for # from (irb):15:in `get_binding' from (irb):15:in `get_binding' from (irb):19 t.