Variable or method

Now I know what this error message really means…

NameError: undefined local variable or method `xxx' for main:Object
[1] pry(main)> foo = 7
=> 7
[2] pry(main)> def foo
[2] pry(main)*   5
[2] pry(main)* end
=> :foo
[3] pry(main)> foo
=> 7

equals

shoot in foot

Turns out, the ‘foo’ method is just a shorthand for ‘self.foo’ so it is still accessible, but a little bit hidden:

[4] pry(main)> self.foo
=> 5