If a variable can only be used by an instance object, such variables are called instance variables. If a variable can be shared by all instance objects of a class, such variables are called class variables.
1) constants can be defined in classes and modules, but not in methods. If a constant in an external struct class or module, use the domain operator ::
2) The global variable starts with $.
3) instance variable. The variable name starts with @; the variable name of the class variable starts @
4) The local variables mentioned in Ruby can exist in classes, methods, modules, loops, and process objects. The local variable name starts with a lowercase letter.
5) a class of things can share a variable and become a class variable. Unlike global variables and instance variables, class variables must be initialized before use. If global variables and instance variables are not initialized, the value is nil.
6) call a class method. Like defining a class method, you must add a class name and a period (.) before the method name. Class methods provide a way to implement class variables outside the class without passing the class instance methods.
Class variables, which correspond to static variables and static methods in Java.