when* ( ..a ? true: ( ..a ? -- ..a ) -- ..a )
Factor handbook » The language » Combinators » Conditional combinators

Prev:if* ( ..a ? true: ( ..a ? -- ..b ) false: ( ..a -- ..b ) -- ..b )
Next:unless* ( ..a ? false: ( ..a -- ..a x ) -- ..a x )


Vocabulary
kernel

Inputs
?a generalized boolean
truea quotation with stack effect ( ..a ? -- ..a )


Outputs
None

Word description
Variant of if* with no false quotation.

The following two lines are equivalent:
X [ Y ] when* X dup [ Y ] [ drop ] if


Definition

: when* ( ..a ? true: ( ..a ? -- ..a ) -- ..a )
over [ call ] [ 2drop ] if ; inline