变量定义(variables):
local: time or _time
instance:
@time class: @@time global
$time
数据类型(data types)
Numeric
String
Symbol
Boolean
Array
Hash
variables tricks(变量应用)
"hello #{name}"
a,b = b,a
3.times{ puts
"hello"}
"hello" * 3
判断语句
1.condition if
质樸的if:
if(a>5)
puts a
end
一行版:
if a > 5 then puts a end
语义不够顺畅:
puts a if a > 5
puts "miss it" if !name
puts "miss it" unless name
三元不能少:
a > 5 ? puts(a) : "oh no"
原文地址:http://www.cnblogs.com/andicu/p/3747270.html