[前][次][番号順一覧][スレッド一覧]

ruby-changes:71492

From: Nobuyoshi <ko1@a...>
Date: Thu, 24 Mar 2022 19:15:40 +0900 (JST)
Subject: [ruby-changes:71492] e6c1db1d8a (master): [DOC] Refine flip-flop

https://git.ruby-lang.org/ruby.git/commit/?id=e6c1db1d8a

From e6c1db1d8a95d3eb52759414660d005a6d109cda Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 24 Mar 2022 19:08:18 +0900
Subject: [DOC] Refine flip-flop

---
 doc/syntax/control_expressions.rdoc | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/doc/syntax/control_expressions.rdoc b/doc/syntax/control_expressions.rdoc
index e91b03e72d..df3b5ced38 100644
--- a/doc/syntax/control_expressions.rdoc
+++ b/doc/syntax/control_expressions.rdoc
@@ -513,9 +513,9 @@ and modifier +if+ has lower precedence than <code>=</code>. https://github.com/ruby/ruby/blob/trunk/doc/syntax/control_expressions.rdoc#L513
 
 == Flip-Flop
 
-The flip-flop is a rarely seen conditional expression.  It's primary use is
-for processing text from ruby one-line programs used with <code>ruby -n</code>
-or <code>ruby -p</code>.
+The flip-flop is a slightly special conditional expression.  One of its
+typical uses is processing text from ruby one-line programs used with
+<code>ruby -n</code> or <code>ruby -p</code>.
 
 The form of the flip-flop is an expression that indicates when the
 flip-flop turns on, <code>..</code> (or <code>...</code>), then an expression
@@ -524,7 +524,6 @@ will continue to evaluate to +true+, and +false+ when off. https://github.com/ruby/ruby/blob/trunk/doc/syntax/control_expressions.rdoc#L524
 
 Here is an example:
 
-
   selected = []
 
   0.upto 10 do |value|
@@ -533,15 +532,16 @@ Here is an example: https://github.com/ruby/ruby/blob/trunk/doc/syntax/control_expressions.rdoc#L532
 
   p selected # prints [2, 3, 4, 5, 6, 7, 8]
 
-In the above example, the on condition is <code>n==2</code>.  The flip-flop
-is initially off (false) for 0 and 1, but becomes on (true) for 2 and remains
-on through 8.  After 8 it turns off and remains off for 9 and 10.
+In the above example, the `on' condition is <code>n==2</code>.  The flip-flop
+is initially `off' (false) for 0 and 1, but becomes `on' (true) for 2 and
+remains `on' through 8.  After 8 it turns off and remains `off' for 9 and 10.
 
-The flip-flop must be used inside a conditional such as +if+, +while+,
-+unless+, +until+ etc. including the modifier forms.
+The flip-flop must be used inside a conditional such as <code>!</code>,
+<code>? :</code>, +not+, +if+, +while+, +unless+, +until+ etc. including the
+modifier forms.
 
-When you use an inclusive range (<code>..</code>), the off condition is
-evaluated when the on condition changes:
+When you use an inclusive range (<code>..</code>), the `off' condition is
+evaluated when the `on' condition changes:
 
   selected = []
 
@@ -555,7 +555,7 @@ Here, both sides of the flip-flop are evaluated so the flip-flop turns on and https://github.com/ruby/ruby/blob/trunk/doc/syntax/control_expressions.rdoc#L555
 off only when +value+ equals 2.  Since the flip-flop turned on in the
 iteration it returns true.
 
-When you use an exclusive range (<code>...</code>), the off condition is
+When you use an exclusive range (<code>...</code>), the `off' condition is
 evaluated on the following iteration:
 
   selected = []
@@ -567,5 +567,5 @@ evaluated on the following iteration: https://github.com/ruby/ruby/blob/trunk/doc/syntax/control_expressions.rdoc#L567
   p selected # prints [2, 3, 4, 5]
 
 Here, the flip-flop turns on when +value+ equals 2, but doesn't turn off on the
-same iteration.  The off condition isn't evaluated until the following
+same iteration.  The `off' condition isn't evaluated until the following
 iteration and +value+ will never be two again.
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]