-
UID:1177
-
- 注册时间2006-03-21
- 最后登录2009-03-24
- 在线时间675小时
-
- 发帖3743
- 搜Ta的帖子
- 精华
1
- 铜板8
- 人品值493
- 贡献值9
- 交易币0
- 好评度3746
- 信誉值0
- 金币0
-
访问TA的空间加好友用道具
- 发帖
- 3743
- 铜板
- 8
- 人品值
- 493
- 贡献值
- 9
- 交易币
- 0
- 好评度
- 3746
- 信誉值
- 0
- 金币
- 0
- 所在楼道
|
最近学习ror 发点ruby基础 AsV8k_qZL no eb f 数值型(Numeric) Q,ZkeWQ7% 1. 整型:分Fixnum和Bignum两类. g]:..W7 2. 浮点型:Float goG]WGVr - 5.class # Fixnum
- 1234567890.class # Bignum
- 3.14.class # Float
M|5^':Y y[TaM9< 字符串类型(String) :h3#1fko - str = “Hello”
- str.class # String
- 'Jellen'.length # 6
- “str: #{str}” # “str: Hello”
- print 'one\ntwo' # 显示one\ntwo
Lx9hq7< BF@m)w.v 范围类型(Range) e,PQ)1 - ptr = 1..3 # 表示1, 2, 3
- ptr.class # Range
- ptr.to_a # [1, 2, 3]
- 'a'...'d' # 表示a, b, c
ch%Q'DR_I) :0i#=ODR 正则表达式(Regexp) 6,sRavs - r = /^Ruby.*/
- r.class # Regexp
- r =~ “Ruby” # 0
- Regexp.new(“qq”) # %r{qq}
DK2c]i^|= 数组类型(Array) GA({r i - Array.new(2) # [nil, nil]
- Array.new(2, 'a') # ['a', 'a']
- a = [1, 'x', [1, 2]]
- a[0] # 1
- a[9] # nil
- a[-1] # [1, 2]
- a[0..1] # [1, 'x']
- a[2][1] # 2
- [1, 2] + [3] # [1, 2, 3]
'5&B~ 1& 哈希列表(Hash) qdg= Imx - a = Hash.new('a') #{}
- a['test'] # 'a'
- h = { 'fire' => 119,
- 'police' => 110 }
- h['fire'] # 119
- h['test'] # nil
- h['ill'] = 120 # 增加一项
uOy\{5s8 代码块(Proc) K*hf(w9="% - p = Proc.new { puts “InProc” }
- p.class # Proc
- p.call # 打印InProc
|