Inputs and outputs
?a generalized boolean
truea quotation
falsea quotation

Word description
If cond is f, calls the false quotation. Otherwise calls the true quotation.

The cond value is removed from the stack before either quotation is called.

USING: io kernel math ; 10 3 < [ "Math is broken" print ] [ "Math is good" print ] if
Math is good

if is executed as a primitive when preceded by two literal quotations. The below definition is not executed unless one of its arguments is a non-literal quotation, such as a quotation constructed with curry or compose, or for Fried quotations or quotations including Lexical variables.


: if
( ..a ? true: ( ..a -- ..b ) false: ( ..a -- ..b ) -- ..b )
? call ;