Variable Fundamental
1 # Declaration and Definition
2 x = 123
3
4 # Find type
5 x.class
6
7 # Type check
8 x.kind_of? Integer
Scope
1 # Local
2 localVar = 0
3
4 # Instance
5 @instanceVar = 0
6
7 # Class
8 @@classVar = 0
9
10 # Global
11 $globalVar = 0
Constants
1 # Definition. Note: the value is mutable.
2 ConstVar = 0
3 puts ConstVar
Parallel Assignment
1 # Assign multiple variables in one line
2 a, b, c = "43", 5.6, 1