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 : ShortcutParameters
conditionThe evaluated logic that determines which branch to follow.
groupingIdentifierAn optional UUID, useful for building deterministic output.
ifTrueThe 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 : ShortcutParameters
conditionThe evaluated logic that determines which branch to follow.
groupingIdentifierAn optional UUID, useful for building deterministic output.
ifTrueThe shortcut builder that creates shortcuts for the “else” branch.
ifTrueThe shortcut builder that creates shortcuts for the “else” branch.
View on GitHub
If Structure Reference