S
Szymon Drejewicz
What do you think about MAIN_BINDING for use it with eval():
eval("a = 'hello'",MAIN_BINDING)
puts a
outputs:
hello
?
eval("a = 'hello'",MAIN_BINDING)
puts a
outputs:
hello
?
What do you think about MAIN_BINDING for use it with eval():
eval("a = 'hello'",MAIN_BINDING)
puts a
outputs:
hello
What do you think about MAIN_BINDING for use it with eval():
eval("a = 'hello'",MAIN_BINDING)
puts a
outputs:
hello
?
Szymon Drejewicz said:What do you think about MAIN_BINDING for use it with eval():
eval("a = 'hello'",MAIN_BINDING)
puts a
outputs:
hello
?
"puts a" command to simply output its value; but if "a" is not
previously defined, my understanding is that "puts a" interprets "a" as
a method call. In this case, "eval" statement (whose command is not, of
course, touched by the interpreter) indeed sets the "a" variable in the
global scope, but the "print" statement doesn't access it.
I'm don't know if there's a syntactical way around this.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.