iOS ● ● ● Swift 6

Kodebits Day 17: Closure Reference Capture

May 4 2026
Practice memory management with a short swift challenge.

What is the output?

var n = 5
let f = { print(n) }
n = 14
f()


Try it in the online Swift Playground →

[spoiler title="Solution"]

Answer:

14

Explanation:

Closures capture variables by reference by default.

[/spoiler]


Further Reading