Variables and other identifiers normally start with an alphabetic letter or a special modifier. The basic rules are as follows:
- Local variables (and pseudovariables such as self and nil) begin with a lowercase letter or an underscore.
- Global variables begin with a $ (dollar sign).
- Instance variables (within an object) begin with an @ (at sign).
- Class variables (within a class) begin with two @ signs.
- Constants begin with capital letters.
- For purposes of forming identifiers, the underscore (_) may be used as a lowercase letter.
- Special variables starting with a dollar sign (such as $1 and $/) are not dealt with here.
- Local variables alpha, _ident, some_var
- Pseudovariables self, nil, __FILE__
- Constants K6chip, Length, LENGTH
- Instance variables @foobar, @thx1138, @NOT_CONST
- Class variable @@phydeaux, @@my_var, @@NOT_CONST
- Global variables $beta, $B12vitamin, $NOT_CONST
No comments:
Post a Comment