Ruby names are used to refer to constants, variables, methods,
classes, and modules. The first character of a name helps Ruby to
distinguish its intended use. Certain names, listed in Table
18.3 on page 210, are reserved words and should not be used as
variable, method, class, or module names.
In these descriptions, lowercase letter
means the characters
``a'' though ``z'', as well as ``_'', the underscore. Uppercase
means ``A'' though ``Z,'' and digit
through ``9.'' Name characters
means any combination of upper-
and lowercase letters and digits.
A local variable name consists of a lowercase letter followed by name
fred anObject _x three_two_one
An instance variable name starts with an ``at'' sign (``
'') followed by an
upper- or lowercase letter, optionally followed by name
A class variable name starts with two ``at'' signs (``
followed by an upper- or lowercase letter, optionally followed by name
A constant name starts with an uppercase letter followed by name characters.
Class names and module names are constants, and follow the constant
naming conventions. By convention, constant variables are normally
spelled using uppercase letters and underscores throughout.
PI = 3.1415926
Global variables, and some special system variables, start with a
dollar sign (``
'') followed by name characters. In addition,
there is a set of two-character variable names in which the second
character is a punctuation character. These predefined variables are
listed starting on page 213. Finally, a global variable name
can be formed using ``
'' followed by any
$params $PROGRAM $! $_ $-a $-.
Method names are described in the section beginning on page 225.