If

public struct If: Fn

If evaluates and returns then expr or else expr depending on the value of pred. If pred evaluates to anything other than a boolean, if returns an “invalid argument” error.

Reference.

  • Declaration

    Swift

    public init(_ pred: Expr, then: Expr, else: Expr)

    Parameters

    pred

    Predicate expression. Must evaluate to a boolean value.

    then

    Expression to execute if pred evaluation is true.

    else

    Expression to execute if pred evaluation is false.