class NameError

当给定的名称无效或未定义时引发。

puts foo

为没有 Bundler 环境的 RubyGems 抛出异常。

NameError: undefined local variable or method `foo' for main:Object

由于常量名必须以大写字母开头

Integer.const_set :answer, 42

为没有 Bundler 环境的 RubyGems 抛出异常。

NameError: wrong constant name answer