result builder transform
Swift ⟩ Attributes ⟩ Result Builders ⟩
Can’t use break, continue, defer, guard(👉 ❓), return, while, do-catch in the code (usaully the body of a closure) that a result builder transforms.
The transformation process doesn’t change declarations in the code, which lets you use temporary constants and variables to build up expressions piece by piece.
It also doesn’t change throw statements, compile-time diagnostic statements, or closures that contain a return statement.
An assignment (=) statement is transformed like an expression, but is understood to evaluate to ()
. You can define an overload of buildExpression(_:)
that takes an argument of type ()
to handle assignments specifically. 👉 Swift Reference
Last updated
Was this helpful?