ts wrote: >>>>>> "E" == Eli Bendersky <eliben / gmail.com> writes: > > E> I'm struggling to fully understand the difference between the block > and > E> the string versions ? > > the string version is evil :-) > It may be evil but it is necessary. Correct me if I am wrong, but this is how I see it - the string version of eval is the only way to differentiate between "evaluation time" and "execution time". Example: name = '"Mike"' evaltime = eval "lambda {name = 'Jane'; puts #{name}}"; runtime = eval "lambda {name = 'Jane'; puts name}"; evaltime.call runtime.call ==> Mike ==> Jane Unless I'm misunderstanding something, this can be only done with the string version of eval. Additionally, stitching pieces of code together, like this: var = '"Jane"' estr = "lambda {name =" + var + "; puts name}" runtime = eval estr runtime.call Can also be done only with the string version. The way I see it, the block version is simply a convenience, making the code cleaner. It is similar to wrapping a string into a single (non-interpolating) quote: class Ab end boor = Ab.new boor.instance_eval { p "using block" def a puts "Ab::a" end } boor.instance_eval %q{ p "using %q" def b puts "Ab::b" end } boor.a boor.b ==> "using block" ==> "using %q" ==> Ab::a ==> Ab::b What have I missed ? Thanks in advance. Eli -- Posted via http://www.ruby-forum.com/.