Skip to content

Commit 85e24cd

Browse files
author
Jesús Gómez
committed
Limit some examples to be just logical expression and not assignments
In the section "Why is using and and or as logical operators a bad idea?" ... Notice the example following given example: ``` foo = true or true and false # => false (it's effectively (true or true) and false) ``` Yes, the whole expression is `false` but be careful: `foo` is `true`. This phenomenal of problems with the assignment was already addressed by the previous example: ``` ---- foo = true and false # results in foo being equal to true. Equivalent to (foo = true) and false bar = false or true # results in bar being equal to false. Equivalent to (bar = false) or true ---- ``` So my suggestion is to limit this last examples to just be logical expressions, or add for each one a new "column" for the variable value. Something enough to express: expression # expression's value # variable's value foo = true or true and false # false # true foz = true || true && false # true # true bar = false or true and false # false # false baz = false || true && false # false # false
1 parent fc0125e commit 85e24cd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

README.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,10 +1499,10 @@ were inspired by Perl, they don't have different precedence in Perl.
14991499
15001500
[source,ruby]
15011501
----
1502-
foo = true or true and false # => false (it's effectively (true or true) and false)
1503-
foz = true || true && false # => true (it's effectively true || (true && false)
1504-
bar = false or true and false # => false (it's effectively (false or true) and false)
1505-
baz = false || true && false # => false (it's effectively false || (true && false))
1502+
true or true and false # => false (it's effectively (true or true) and false)
1503+
true || true && false # => true (it's effectively true || (true && false)
1504+
false or true and false # => false (it's effectively (false or true) and false)
1505+
false || true && false # => false (it's effectively false || (true && false))
15061506
----
15071507
****
15081508

0 commit comments

Comments
 (0)