Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Use This Attribute To Require That All Class Properties Are Initialized

Use This Attribute To Require That All Class Properties Are Initialized

Daily Coding Tip 190

Type Safely's avatar
Type Safely
Oct 07, 2022
∙ Paid

Share this post

Type Safely
Type Safely
Use This Attribute To Require That All Class Properties Are Initialized
Share
purple shutter doors
Photo by JOSHUA COLEMAN on Unsplash

Here’s an attribute that can be applied to classes.

If I add a property to a class called MyClass, for instance var string: String, the compiler will complain that MyClass has no accessible initializers. It won’t actually have an issue with you creating an initializer that doesn’t actually do anything to set the string,…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share