ThoML wrote:
> Okay, I missed the deeper meaning of eval in your example.
> 
>     eval("lambda {#{IO.read(file)} }")
> 
> Maybe:
> 
>     @task = if file
>                 ruby = file.read file
>                 lambda { eval ruby }
>             else
>                 block
>             end
> 
>> I'm not necessarily looking for the simplest solution, I'm looking for
>> the best solution.  Both of the examples I posted have the same results,
>> it's just how they are implemented.
> 
> The second one creates the method in the class though which most
> likely
> isn't what you want.
> 
>     irb(main):032:0> j = JobB.new('test.rb')
>     => #<JobB:0x7fec2adc>
>     irb(main):034:0> JobB.instance_method(:do)
>     => #<UnboundMethod: JobB#do>
> 
> If you want to minimize the context, create a new method that gets
> nothing but the file name as argument and returns the block for the
> file. I think that's what's meant in the blog post.


so what would be the difference between:

x = eval "lambda { #{IO.read(file)}" }"
x.call

y = lambda { eval IO.read(file) }
y.call


I'm guessing that in the first eval gets called only the one time where 
in the second, eval gets called with every y.call.  (this is why i did 
it the way i did, if i am incorrect, then please let me know)
-- 
Posted via http://www.ruby-forum.com/.