If

public struct If : Shortcut

Tests if a condition is true, and if so, runs the actions inside. Otherwise, the actions under “Otherwise” are run.

Input: Anything

Result: (Anything) The input

  • The contents of the shortcut.

    Declaration

    Swift

    public var body: some Shortcut { get }
  • Initializes the shortcut with no “else” branch.

    Declaration

    Swift

    public init<TrueContent>(_ condition: Condition, groupingIdentifier: UUID = UUID(), @ShortcutBuilder then ifTrue: () -> TrueContent) where TrueContent : Shortcut

    Parameters

    condition

    The evaluated logic that determines which branch to follow.

    groupingIdentifier

    An optional UUID, useful for building deterministic output.

    ifTrue

    The shortcut builder that creates shortcuts for the “then” branch.

  • Initializes the shortcut with both “then” and “else” branches.

    Declaration

    Swift

    public init<TrueContent, FalseContent>(_ condition: Condition, groupingIdentifier: UUID = UUID(), @ShortcutBuilder then ifTrue: () -> TrueContent, @ShortcutBuilder else ifFalse: () -> FalseContent) where TrueContent : Shortcut, FalseContent : Shortcut

    Parameters

    condition

    The evaluated logic that determines which branch to follow.

    groupingIdentifier

    An optional UUID, useful for building deterministic output.

    ifTrue

    The shortcut builder that creates shortcuts for the “else” branch.

    ifTrue

    The shortcut builder that creates shortcuts for the “else” branch.