Scope
let x = 10
fun f(): Int {
let y = 10
return x + y
}
f() // is `20`
// Invalid: the identifier `y` is not in scope.
//
yfun doubleAndAddOne(_ n: Int): Int {
fun double(_ x: Int) {
return x * 2
}
return double(n) + 1
}
// Invalid: the identifier `double` is not in scope.
//
double(1)Last updated