Whitespace in Ruby Program:
Whitespace characters such as spaces and tabs are generally ignored in Ruby code, except when they appear in strings. Sometimes, however, they are used to interpret ambiguous statements. Interpretations of this sort produce warnings when the -w option is enabled.
Example:
a + b is interpreted as a+b ( Here a is a local variable)
a +b is interpreted as a(+b) ( Here a is a method call)
Line Endings in Ruby Program:
Ruby interprets semicolons and newline characters as the ending of a statement. However, if Ruby encounters operators, such as +, -, or backslash at the end of a line, they indicate the continuation of a statement.
(;表示结束。+,-,反斜杠表示换行)
Ruby Identifiers:(标识符)
Identifiers are names of variables, constants, and methods. Ruby identifiers are case sensitive. It mean Ram and RAM are two different itendifiers in Ruby.(大小写敏感)
Ruby identifier names may consist of alphanumeric characters and the underscore character ( _ ). (命名可以包含数字,字母以及下划线)
Reserved Words:(预留字)
The following list shows the reserved words in Ruby. These reserved words may not be used as constant or variable names. They can, however, be used as method names.
BEGIN do next then
END else nill true
alias elsif not undef
and end or unless
begin ensure redo until
break false rescue when
case for retry while
class if return while
def in self __FILE__
Whitespace characters such as spaces and tabs are generally ignored in Ruby code, except when they appear in strings. Sometimes, however, they are used to interpret ambiguous statements. Interpretations of this sort produce warnings when the -w option is enabled.
Example:
a + b is interpreted as a+b ( Here a is a local variable)
a +b is interpreted as a(+b) ( Here a is a method call)
Line Endings in Ruby Program:
Ruby interprets semicolons and newline characters as the ending of a statement. However, if Ruby encounters operators, such as +, -, or backslash at the end of a line, they indicate the continuation of a statement.
(;表示结束。+,-,反斜杠表示换行)
Ruby Identifiers:(标识符)
Identifiers are names of variables, constants, and methods. Ruby identifiers are case sensitive. It mean Ram and RAM are two different itendifiers in Ruby.(大小写敏感)
Ruby identifier names may consist of alphanumeric characters and the underscore character ( _ ). (命名可以包含数字,字母以及下划线)
Reserved Words:(预留字)
The following list shows the reserved words in Ruby. These reserved words may not be used as constant or variable names. They can, however, be used as method names.
BEGIN do next then
END else nill true
alias elsif not undef
and end or unless
begin ensure redo until
break false rescue when
case for retry while
class if return while
def in self __FILE__
defined?modulesuper__LINE__
摘自http://www.tutorialspoint.com/ruby/ruby_syntax.htm