What is the result of the following line?
if 13 < 42 [print "13 < 42"] [print "13 > 42"] ; 13 < 42 ;== [print "13 > 42"]
As you can see, it prints out 13 < 42 correctly, but the return value is the following:
[print "13 > 42"]
This is normal behavior—this block comes after the if, so it is returned as a block.
In contrast to most other programming languages, the if in Red does not have an else branch, so be aware of this behavior!
If you need an if…else structure, use either. So for the preceding statement, use the following:
either 13 < 42 [print "13 < 42"][print "13 > 42"] ;== 13 < 42
This puts out the expected result of 13 < 42. The other branch is used when we use >instead of <:
either 13 > 42 [print "13 > 42"][print "13 < ...