class NameError
Raised when a given name is invalid or undefined.
puts foo
raises the exception:
NameError: undefined local variable or method `foo' for main:Object
Since constant names must start with a capital:
Fixnum.const_set :answer, 42
raises the exception:
NameError: wrong constant name answer
Public Class Methods
new(msg [, name]) → name_error Show source
static VALUE name_err_initialize(int argc, VALUE *argv, VALUE self) { VALUE name; name = (argc > 1) ? argv[--argc] : Qnil; rb_call_super(argc, argv); rb_iv_set(self, "name", name); return self; }
Construct a new NameError exception. If given the name parameter may subsequently be examined using the NameError.name
method.
Public Instance Methods
name → string or nil Show source
static VALUE name_err_name(VALUE self) { return rb_attr_get(self, rb_intern("name")); }
Return the name associated with this NameError exception.
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.