inexplicable "undefined local variable" error`

T

Tom Cloyd

This makes no sense to me, so...I could use a little help

In my main program I read in some ruby from an external file:

eval( File.read( "../lib/setnet/Utilities.rb" ) )

I check a variable which should now be defined (by a line in that file),
using ruby-debug:

Breakpoint 1 at SN.rb:550
../lib/setnet/SN.rb:550
pp menu_ut # <= my main program code about to execute, so menu_ut
better be there
(rdb:1) p defined? menu_ut
"local-variable" # <= looks good
(rdb:1) p menu_ut # <= this successfully prints the expected contents
of this array.
[...]
(rdb:1) c # now the above line of program code should execute without
error...and we get instead...

../lib/setnet/SN.rb:550:in `proc_command': undefined local variable or
method `menu_ut' for #<SN::SetNet:0xb79adac8> (NameError)

...and it blows.

How can this be?

I do know that if I make this variable a constant, in the input file,
all is well. But I had thought an ordinary variable would be fine, as
the input code is evaluated in the current binding...only it doesn't
seem to be there (the variable), unless you ask ruby-debug, which says
it is.

I cannot make sense of this. And...I need to fix it somehow.

All suggestions most welcome.

Tom
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top