On this page:
top
up

3.16Guarded Evaluation: when and unless πŸ”— i

+Effects If...: when and unless in The Racket Guide introduces when and unless .

syntax

( when test-exprbody...+)

Evaluates test-expr. If the result is #f, then the result of the when expression is #<void>. Otherwise, the bodys are evaluated, and the last body is in tail position with respect to the when form.

Examples:
> (when (positive? -5)
(display "hi"))
> (when (positive? 5)
(display "hi")
(display " there"))

hi there

syntax

( unless test-exprbody...+)

Equivalent to (when (not test-expr)body...+ ).

Examples:
(display "hi"))
> (unless (positive? -5)
(display "hi")
(display " there"))

hi there

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /