What is the output?
struct Config {
lazy var value: Int = {
print("Init")
return 42
}()
}
var cfg = Config()
print("Start")
print(cfg.value)
Try it in the online Swift Playground →
[spoiler title="Solution"]
Answer:
Start Init 42
Explanation:
Lazy properties defer initialization until first access.
[/spoiler]