Depending on the value of the units parameter, I would like to unwrap the Fahrenheit or Celsius temperature using guard. However, I get an error about
Use of unresolved identifier 'temp'
from the following example code
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 }
}
Why does guard not work in this example?
Aucun commentaire:
Enregistrer un commentaire