Ruby Syntax:
1: Variable
2: Comment
3: embedded document
4: Reserved Words
Ruby currently uses the ASCII character set. It can recognize uppercase and lowercase letters. In addition to the variable and part of the direct amount, you can
Add spaces and comments anywhere, including spaces, tabs, vertical tabs, backspace, carriage return, line breaks, and page breaks. When
When the code continues to be written with a line feed, except for spaces, other statements are interpreted as separate statements. (Note: When the code is too long to be written
Only spaces can be added in the middle; otherwise, an error will occur)
<1> variables:
Example: foobarruby_is_simple
Ruby variable names can start and end with letters or underscores. There is no limit on the length of the variable name.
<2> note:
Example: # This is a comment line
Following the script language's habits, strings and numbers are directly counted, '? # ', From the beginning to the end of the line is considered as a comment
(Note: Comments in Perl are also used #)
<3> embedded document:
Example: = beginthe everything between a line beginning with '= begin' andthat with '= end' will be skipped by the interpreter. = end
(Note: embedded documents in Perl are also expressed in this way)
You can embed a document in the source code of Ruby. The start part of the document starts with = begin until = end.
In this form, the Ruby interpreter cannot limit the annotation content. It is best to use the annotation in the form of RD (Ruby document format.
<4> reserved words:
The following are reserved words:
BEGIN class ensure nil self whenEND def false not super whilealias defined? for or then yieldand do if redo truebegin else in rescue undefbreak elsif module retry unlesscase end next return until
Reserved Words cannot be used in class names or variable names. However, if the prefix $, @, and @ is added, they are not considered reserved words. In addition, after def or
After the terminator of a method call, it is clear that these reserved words can be used as the method name.