if at the end of the sentence (#24428)

pull/25213/head^2
邱斯 2019-01-04 01:49:32 +08:00 committed by Jingyi Ding
parent 6bcaf0ee52
commit 6cfde0060c
1 changed files with 10 additions and 4 deletions

View File

@ -20,15 +20,21 @@ Ruby有几个常用的条件。
end
```
### 除非声明
## 除非声明
除非语句与if语句相反。它与否定的if语句相同。
* `ruby happy = true if !happy puts "This person is not happy" end` 以上陈述等同于以下陈述
* `ruby unless happy puts "This person is not happy" end`
## 句尾条件
在ruby当里我们也常将条件至于句尾
* `puts "Your fruit is an apple" if fruit == :apple`
* `puts "This is not an apple" unless fruit == :apple`
## 三元声明
三元语句用作短条件语句。它写成如下
@ -51,4 +57,4 @@ case语句类似于if / elsif / else语句
puts "This is not an apple or an orange"
end
```
```