1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
unless false
"ok"
end
# => "ok"
## if/unless
a = 1 if a != 1 #如果a不是1 则a复制为1
b = 2 unless defined?(b) #如果b未定义 那么就定义b赋值为2
## case
case a
when 1
1
when /hello/
"hello world"
when Array
[]
else
"ok"
end
## while
a = 0
while a < 100 do
p a
a += 1
end
|