Swift Quick Tip: lazy variables
Published in
1 min readAug 1, 2019
You can replace:
With:
The object SomeObject will only be instantiated when referenced/needed. This lazy behaviour may potentially save memory in case the object is never referenced in a given code path, and guarantee the object is always defined if needed without having to resort to using “!” and potentially referencing the object before it is initialized.