A
Adelle Hartley
Hi all,
I have been using eval to execute code fragments that I fetch from a
database.
Imagine my surprise when I discovered that the following does not work when
executed by eval:
unless thing.nil?
puts "I have something"
else
puts "nothing here"
end
This works as expected when executed "properly" (from within a regular
normal .rb file).
I don't seem able to make any conditional code work correctly with eval,
unless the conditinoal branch is a one liner:
puts "I have something" unless thing.nil?
Are the limitations of eval documented somewhere (or is it possible that I'm
just not doing it right)?
Adelle.
I have been using eval to execute code fragments that I fetch from a
database.
Imagine my surprise when I discovered that the following does not work when
executed by eval:
unless thing.nil?
puts "I have something"
else
puts "nothing here"
end
This works as expected when executed "properly" (from within a regular
normal .rb file).
I don't seem able to make any conditional code work correctly with eval,
unless the conditinoal branch is a one liner:
puts "I have something" unless thing.nil?
Are the limitations of eval documented somewhere (or is it possible that I'm
just not doing it right)?
Adelle.