Ruby语言入门(3)- 标识
上一篇 /
下一篇 2013-01-29 14:31:38
/ 个人分类:语言
标识符
Ruby的标识符的首位由字母或下划线('_')构成,后面部分可以是字母、下划线('_')或数字。对标识符的长度没有限制。
注释行
Ruby以#开始的行当作注释行来处理。 字符串内部和数值字面值中的“#”除外。
# this is a comment line
内嵌文档
行首为=begin的行开始到行首为=end的行为止的部分就是内嵌文档,这部分代码被忽略,一般用于较长的解释
=begin
the everything between a line beginning with `=begin' and
that with `=end' will be skipped by the interpreter.
=end
保留字
下列词语就是Ruby的保留字:
BEGIN class ensure nil self when
END def false not super while
alias defined? for or then yield
and do if redo true
begin else in rescue undef
break elsif module retry unless
case end next return until
保留字不可用作类名和变量名。
收藏
举报
TAG: