script local variables - the root of all mystery?

J

Jason Dusek

I have a script with top level variables in it (i.e - variables that
are not declared within a block, function definition or class
definition). When I run this script through irb with load, I can
access the variables just as though I had defined them in irb. Cool!

Then I added a true global variable - $opts - to my script. I run it
through irb and, lo and behold, I can't get at those top level
variables anymore. What happenned? Did declaring the global variable
somehow sink my script into its own context?
 
J

Jason Dusek

I don't know why this gets sent twice. All my other proxied mail
accounts behave fine.
 
S

shortcutter

Jason said:
I have a script with top level variables in it (i.e - variables that
are not declared within a block, function definition or class
definition). When I run this script through irb with load, I can
access the variables just as though I had defined them in irb. Cool!

Then I added a true global variable - $opts - to my script. I run it
through irb and, lo and behold, I can't get at those top level
variables anymore. What happenned? Did declaring the global variable
somehow sink my script into its own context?

I cannot exactly tell what went wrong in your case but I do know that
IRB cannot be trusted once local variables are involved.

Maybe post the script so we get a better impression of what is going
on?

Kind regards

robert
 

Ask a Question

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.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top