?unless ( ..a default cond: ( ..a default -- ..a new/f ) false: ( ..a default -- ..b ) -- ..b )
Factor handbook » The language » Combinators » Conditional combinators

Prev:?when ( ..a default cond: ( ..a default -- ..a new/f ) true: ( ..a new -- ..b ) -- ..b )
Next:? ( ? true false -- true/false )


Vocabulary
kernel

Inputs
defaultan object
condan object
falsean object


Outputs
None

Word description
Calls cond on the default object and if cond outputs a new object. Otherwise, calls false with the old object.

Examples
Look up an existing word or make an error pair:
USING: arrays definitions kernel math prettyprint sequences vocabs.parser ; "+" [ search ] [ "not found" 2array ] ?unless .
+


Try to look up a word that doesn't exist:
USING: arrays definitions kernel math prettyprint sequences vocabs.parser ; "+++++" [ search ] [ "not found" 2array ] ?unless .
{ "+++++" "not found" }


See also
?if, ?when

Definition

: ?unless
( ..a default cond: ( ..a default -- ..a new/f ) false: ( ..a default -- ..b ) -- ..b )
[ ?transmute ] dip unless ; inline