
Next: Let
Up: Conditionals
Previous: Cond and Case
The when and unless forms conditionally evaluate
a single body of expressions:
- (when test expr
)
evaluates the expr body expressions only when test
returns a true value. - (unless test expr
)
evaluates the expr body expressions only when test
returns #f.
The result of a when or unless expression is the
result of the last body expression if the body is evaluated, or
#<void> if the body is not evaluated.
The begin0 form is like begin, but the value of
the first expression in the form is returned instead of the last
expression:
(let ([x 4])
(begin0 x (set! x 9) (display 'done))) ; => displays done then returns 4
PLT