I was using an if-let statement to assign a variable a value only if the corresponding text field was not empty.
var AB: Double? {
if let abText = sideAB.text, ab = Double(abText) {
return ab
} else {
return nil
}
}However, I received the error message
fatal error: unexpectedly found nil while unwrapping an Optional value.I thought "if-let" statements prevented this, so why did it still happen and how can I stop it from happening?