Programming in Swift: Functions & Types, Episode 31: Lazy Properties | raywenderlich.com

In this episode, learn about the lazy keyword and how it can help you avoid expensive calculations until you need them.


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

Hello!
Quick question: on the very last part of the video, the image goes: β€œIs your constant: …” But I think that lazy can only be used with var as constant properties must have a value at initialisation. Yes? No? What I dont get and I have to set it right ? :slight_smile:
Thanks for your time!

1 Like

Hi there! You are correct about constants, and you are definitely not the first person to ask me about this particular bit :grimacing: What I meant is that if you have a constant that meets these criteria, consider turning that constant into a lazy variable instead.

1 Like

Noted! Thanks for reply !