Wondering why a variable is undefined in Ruby?
Getting an error like this? NameError: undefined local variable or method `a’ for #
1. Might be something to do with scope.
Check out these posts on Scope Gates (i.e. when you enter / leave a Class, Module or Method definition your scope changes):
2. Or you’ve referred to a local variable that doesn’t yet exist. E.g.
will raise a NameError exception in Ruby. But,
a = 10
will not as the variable has been defined.