Perish

博客园 首页 联系 订阅 管理

1、变量和常量:

全局变量用$;   实例变量用@;   类变量用@@;

Local Variable:  name fish_and_chips x_axis thx1138 _x _26
Instance Variable:   @name @point_1 @X @_ @plan9
Class Variable:  @@total @@symtab @@N @@x_pos @@SINGLE
Global Variable:   $debug $CUSTOMER $_ $plan9 $Global
Class Name: String ActiveRecord MyClass
Constant Name:   FEET_PER_MILE DEBUG

2、数组

a = [ 'ant', 'bee', 'cat', 'dog', 'elk' ]
a[0]  # => "ant"
a[3]  # => "dog"
# this is the same:
a = %w{ ant bee cat dog elk }
a[0]  # => "ant"
a[3]  # => "dog"


posted on 2014-06-16 15:20  ---小青年---  阅读(310)  评论(0编辑  收藏  举报