Ruby语言入门(3)- 标识

上一篇 / 下一篇  2013-01-29 14:31:38 / 个人分类:语言

标识符

Ruby的标识符的首位由字母或下划线('_')构成,后面部分可以是字母、下划线('_')或数字。对标识符的长度没有限制。

foobar
_ruby_is_simple

注释行

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:

 

评分:0

我来说两句

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 150958
  • 日志数: 185
  • 文件数: 6
  • 建立时间: 2007-08-06
  • 更新时间: 2015-01-06

RSS订阅

Open Toolbar