This compiles in Xcode, but fails in Fire .2485 (Android library) with “Duplicate variable”:
class ValueClass {
private var values = [Int: String]()
public subscript(anID: Int) -> String? {
guard let result: String = values[anID] else {
let result: String = "NewValue"
values[anID] = result
return result
}
return result
}
}
AFAIK variable defined by guard let/var statement is only available “outside” guard statement, i.e. if guard is successful. So, as far as code “inside” guard statement is concerned, the variable was never defined because guard was not successful. So it can be safely defined (again). Xcode compiles it. Just my 2c, it’s not a show stopper.