Hi guys,
I'm working through the Big Nerd Ranch iOS/Swift book and there is a line where the code looks like this:
My question is why is the exclamation point in front of the variable name? I see this occasionally in Swift code but have yet to find an explanation for it. If it is a force unwrap why is it up front?
EDIT: I'm so dumb. Its a "not" operator. Damn Swift and its crazy !'s everywhere had me confused.
I'm working through the Big Nerd Ranch iOS/Swift book and there is a line where the code looks like this:
Code:
if let text = textField.text where !text.isEmpty {
celsiusLabel.text = text
}
else {
celsiusLabel.text = "???"
}
}
My question is why is the exclamation point in front of the variable name? I see this occasionally in Swift code but have yet to find an explanation for it. If it is a force unwrap why is it up front?
EDIT: I'm so dumb. Its a "not" operator. Damn Swift and its crazy !'s everywhere had me confused.
Last edited: