Group Group Group Group Group Group Group Group Group

Lazy Properties | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5429279-programming-in-swift-functions-and-types/lessons/31

in 4:45: “Lazy variables could be a constant”
It’s wrong lazy properties cannot be constants

Hi! Thanks for your comment. You’re right! Lazy variables cannot be constants, they have to be variable.

The text on the slide is not representing what I meant, here, and I’ll make a note to update it. I do explain, after the slide appears, but I’ll rephrase a bit to hopefully make it more clear:

If you have a property that you would normally define as a constant, because you don’t expect the value to change, you might consider using a lazy variable instead if the value of that property would expensive to calculate and the property may not be used by every instance.

Understood, thank you catie for clearing that up.

1 Like