mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
[red/en] Fix logic in "either" examples (#2800)
This commit is contained in:
parent
613702282f
commit
6e7c5c7933
@ -136,14 +136,14 @@ if a < 0 [print "a is negative"]
|
|||||||
; Evaluate a block of code if a given condition is true, else evaluate an
|
; Evaluate a block of code if a given condition is true, else evaluate an
|
||||||
; alternative block of code. If the last expressions in both blocks have the
|
; alternative block of code. If the last expressions in both blocks have the
|
||||||
; same type, EITHER can be used inside an expression.
|
; same type, EITHER can be used inside an expression.
|
||||||
either a < 0 [
|
either a > 0 [
|
||||||
|
msg: "positive"
|
||||||
|
][
|
||||||
either a = 0 [
|
either a = 0 [
|
||||||
msg: "zero"
|
msg: "zero"
|
||||||
][
|
][
|
||||||
msg: "negative"
|
msg: "negative"
|
||||||
]
|
]
|
||||||
][
|
|
||||||
msg: "positive"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
print ["a is " msg lf]
|
print ["a is " msg lf]
|
||||||
@ -151,14 +151,14 @@ print ["a is " msg lf]
|
|||||||
; There is an alternative way to write this
|
; There is an alternative way to write this
|
||||||
; (Which is allowed because all code paths return a value of the same type):
|
; (Which is allowed because all code paths return a value of the same type):
|
||||||
|
|
||||||
msg: either a < 0 [
|
msg: either a > 0 [
|
||||||
|
"positive"
|
||||||
|
][
|
||||||
either a = 0 [
|
either a = 0 [
|
||||||
"zero"
|
"zero"
|
||||||
][
|
][
|
||||||
"negative"
|
"negative"
|
||||||
]
|
]
|
||||||
][
|
|
||||||
"positive"
|
|
||||||
]
|
]
|
||||||
print ["a is " msg lf]
|
print ["a is " msg lf]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user