In the code below, let x = 42
appropriately gives us an 'x' was never used
warning. However the let z = 42
does not. Is there some intention behind this, or is it an oversight in Xcode?
class Foo {
lazy var y: Int = {
let z = 42
return 12
}()
func run() {
let x = 42 // Initialization of immutable value 'x' was never used...
}
}
Bonus info:
class Foo {
lazy var y: Int = {
let z = 42 // No Warning
return 12
}()
var a: Int {
let z = 42 // Warning
return 12
}
let b: Int = {
let z = 42 // No Warning
return 12
}()
func run() {
let x = 42 // Warning goes away, as X is now captured below
var b: Int {
let z = 12 // Warning
return 42
}
let c: Int = { // Warning, as c is unused
let z = 42 // Warning
return 12
}()
}
}