Ruby 中有好几种不同类型的标识符
- constants
- global variables
- instance variables
- class variables
- local variables
# 变量名的首字母是大写的
Pi = 3.14
module Math # module name is capitalized
PI = 3.1415926 # constant is capitalized
class DoubleFloating # class name is capitalized
@@num_objs = 0
def initialize
@@num_objs += 1
@value = 0.0
end
end
end
内建变量
nil, true, false, self