[Pdx-pm] Answer to Ruby question

Phil Tomson ptkwt at aracnet.com
Thu Nov 14 01:04:47 CST 2002


Hi,

Good meeting this evening...

Someone asked me a question about what happens in Ruby when you have a 
typo in your variable name and try to assign an undefined variable to 
another like so:

astring = "this is a string"
b = asting

When you try to run ruby on this, ruby reports:
undefined.rb:2: undefined local variable or method `asting' for 
#<Object:0x401d9ce0> (NameError)

So the fact that there has never been an assignment to the variable 
'asting' is caught.
I've seen this many times, I'm not sure why I didn't remember that ;-)A


Phil





More information about the Pdx-pm-list mailing list