Skip to content
TurtleKitty edited this page May 10, 2019 · 2 revisions

if

This is the primitive conditional. It accepts expressions for a predicate, a consequent, and an alternative. If the predicate evaluates to true, the consequent is evaluated; otherwise, the alternative is evaluated.

If will send the to-bool message to any object given as a predicate.

(if true 'foo 'bar)        ; foo
(if false 'foo 'bar)       ; bar
(if 1 'foo 'bar)           ; foo
(if 0 'foo 'bar)           ; bar
(if "vaquero" 'foo 'bar)   ; foo
(if "" 'foo 'bar)          ; bar
(if (list 5) 'foo 'bar)    ; foo
(if () 'foo 'bar)          ; bar
Clone this wiki locally