if at the end of the sentence (#24428)

This commit is contained in:
邱斯
2019-01-04 01:49:32 +08:00
committed by Jingyi Ding
parent 6bcaf0ee52
commit 6cfde0060c

View File

@ -21,14 +21,20 @@ Ruby有几个常用的条件。
```
### 除非声明
## 除非声明
除非语句与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`
## 三元声明
三元语句用作短条件语句。它写成如下