Forum: Ruby inexplicable "undefined local variable" error`

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D15a45a973443d4562051eb675b60474?d=identicon&s=25 Tom Cloyd (Guest)
on 2009-05-06 12:20
(Received via mailing list)
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( "../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
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.

This topic is locked and can not be replied to.