Depending on the value of the
units
guard
Use of unresolved identifier 'temp'
let units = 0
if units == 0 {
guard let temp = currentDict["temp_f"] as? String else { return nil }
} else {
guard let temp = currentDict["temp_c"] as? String else { return nil }
}
guard
It doesn't work because temp
was scoped to be within the if
statement only. Try this instead:
let key = units == 0 ? "temp_f" : "temp_c"
guard let temp = currentDict[key] as? String else { return nil }