3 ms·
"IfThenElse" in Rebol (called either) is also just a function with 3 args: either 1 = 1 [print "true!"] [print "false!"] Here's an example of writing this
by draegtun 10y ago
"IfThenElse" in Rebol (called either) is also just a function with 3 args:
either 1 = 1 [print "true!"] [print "false!"]
Here's an example of writing this in Rebol directly:
if-then-else: function [
cond [logic!]
true-block [block!]
false-block [block!]
][
switch cond [
#[true] [do true-block]
#[false] [do false-block]
]
]
This works because blocks aren't evaluated until explicitly called:
>> if-then-else 1 = 1 [print "true!"] [print "false!"]
true!
>> if-then-else 1 = 2 [print "true!"] [print "false!"]
false!