svanimpe
(Steven Van Impe)
1
I've noticed that the REPL assigns default values when declaring (but not initializing) a variable:
1> var d: Double
d: Double = 0
2> var i: Int
i: Int = 0
3> var t: (Int, Int)
t: (Int, Int) = {
0 = 0
1 = 0
}
4> var f: (Int) -> Int
f: (Int) -> Int =
5> var b: Bool
b: Bool = false
Is this behavior documented somewhere? Is this even intentional, or is it just showing the contents of memory?
I believe this is a recent change, as I remember seeing a "top-level variable must be initialized" error for at least some of these examples with Swift 4.