Init accessors are a new feature in Swift 5.9, and they sit right alongside get
and set
accessors, and even the underscored _read
and _modify
accessors that have not been “officially” added to the language yet.
Init accessors allow you to write initializers that set computed properties in the type even before all of the stored properties are set. This was a necessity in order to make macros work as seamlessly as possible.
This is an excerpt from our series of episodes on the Observation framework in Swift.
👋 Hey there! If you got this far, then you must have enjoyed this post. You may want to also check out Point-Free, a video series covering advanced programming topics in Swift. Consider subscribing today!