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