Exception: NameError
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
| Subclasses: | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
          ::StandardError,
          ::Exception
         | |
| Instance Chain: 
          self,
          ::StandardError,
          ::Exception
         | |
| Inherits: | StandardError 
 | 
| Defined in: | error.c, error.c | 
Overview
Raised when a given name is invalid or undefined.
puts fooraises the exception:
NameError: undefined local variable or method `foo' for main:ObjectSince constant names must start with a capital:
Integer.const_set :answer, 42raises the exception:
NameError: wrong constant name answerClass Method Summary
- 
    
      .new([msg, *, name])  ⇒ name_error 
    
    constructor
    Construct a new NameErrorexception.
::Exception - Inherited
| .exception | With no argument, or if the argument is the same as the receiver, return the receiver. | 
| .new | Construct a new ::Exception object, optionally passing in a message. | 
Instance Method Summary
- 
    
      #local_variables  ⇒ Array 
    
    Return a list of the local variable names defined where this NameErrorexception was raised.
- 
    
      #name  ⇒ String? 
    
    Return the name associated with this NameErrorexception.
- 
    
      #receiver  ⇒ Object 
    
    Return the receiver associated with this NameErrorexception.
::Exception - Inherited
| #== | Equality—If obj is not an ::Exception, returns  | 
| #backtrace | Returns any backtrace associated with the exception. | 
| #backtrace_locations | Returns any backtrace associated with the exception. | 
| #cause | Returns the previous exception ($!) at the time this exception was raised. | 
| #exception | With no argument, or if the argument is the same as the receiver, return the receiver. | 
| #inspect | Return this exception's class name and message. | 
| #message | Returns the result of invoking  | 
| #set_backtrace | Sets the backtrace information associated with  | 
| #to_s | Returns exception's message (or the name of the exception if no message is set). | 
Constructor Details
    .new([msg, *, name])  ⇒ name_error   
Construct a new NameError exception. If given the name parameter may subsequently be examined using the #name method.
Instance Method Details
#local_variables ⇒ Array
Return a list of the local variable names defined where this NameError exception was raised.
Internal use only.
#name ⇒ String?
Return the name associated with this NameError exception.
#receiver ⇒ Object
Return the receiver associated with this NameError exception.