On this page
Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class · Ruby 4.1
NameError
Raised when a given name is invalid or undefined.
Example
puts foo
raises the exception:
NameError: undefined local variable or method `foo' for main:Object
Since constant names must start with a capital:
Example
Integer.const_set :answer, 42
raises the exception:
NameError: wrong constant name answer