Ruby processes single quotes and double quotes differently.
(1) double quotation marks can be applied to escape characters
(2) strings in double quotation marks can be replaced by # {varname}. For global variables or instance variables, the {} symbol is not required. ------ I don't quite understand the differences between the two variables
Nil is also an object in Ruby, but it means nothing.
The statement of Ruby's control structure does not have a scratch sign. End indicates the end.
The numeric type in ruby is immutable, that is, the passed value, not the reference.
Chapter 3: definitions of Objects
In the definition of the Ruby class, the constructor is the initialize function, a new object is initialized to XX. New, And the tostring method of Ruby is to_s.
Adding a new method to Ruby is too high, as long as it is directly added, it is more flexible than Js.
Ruby inheritance uses the <symbol. Super calls the method of the same name of the parent class.
Ruby's @ instance variable is equivalent to a private field and cannot be accessed externally. to access it, you must define a method similar to the attribute to return a result. Attr_reader: name,: age,: sex, attr_reader
Is a keyword to simplify this operation. This is actually a method, which is a manifestation of Ruby metaprogramming and will dynamically generate the passed parameters.
Def name = (name)
@ Name = Name
End
This is a way to define writable attributes. Remember to end with =.
Class variables are declared as @, which is equivalent to static methods and private. To be accessed externally, you must open the classname. var.
Import external files using the load 'xxx. rb' method.
It should be said that too many keywords are used to write a singleton mode...
There are also three access control levels, but the syntax is different. The method of putting them in the final declaration is more elegant.