From 6cfde0060c6798b83a2916f05e9adfd198cbe4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E6=96=AF?= <105703029@nccu.edu.tw> Date: Fri, 4 Jan 2019 01:49:32 +0800 Subject: [PATCH] if at the end of the sentence (#24428) --- guide/chinese/ruby/ruby-conditionals/index.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/guide/chinese/ruby/ruby-conditionals/index.md b/guide/chinese/ruby/ruby-conditionals/index.md index af4c77dd05..77674b2452 100644 --- a/guide/chinese/ruby/ruby-conditionals/index.md +++ b/guide/chinese/ruby/ruby-conditionals/index.md @@ -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 - ``` \ No newline at end of file + ```