ruby has 4 kinds of variables,
I found instance variable always come out in a class, which made me confused what's the difference between class variable and instance variable.
Some things like this is java, a pure OO language. The key point is that, instance variable is for differing class static variable from itself. class static variable is shared by all instance of the class, while instance variable is owned by every class instance.
$ | global variable |
@ | instance variable |
[a-z] or _ | local variable |
[A-Z] | constant |
Some things like this is java, a pure OO language. The key point is that, instance variable is for differing class static variable from itself. class static variable is shared by all instance of the class, while instance variable is owned by every class instance.