iOS ● ● ○ Swift 6

Kodebits Day 45: Lazy Property Init

Jun 22 2026
Practice properties with a short swift challenge.

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]


Further Reading