In the code below, I'm confused as to where the return
statement in the code returns to? When executed, it works as expected, but does it return to:
if userIsInTheMiddleOfTyping == true
or does it return to:
if let digit = sender.currentTitle
Below is the full chunk of code where this applies.
class ViewController: UIViewController {
private var userIsInTheMiddleOfTyping = false
private var decimalUsed = false
@IBAction private func touchDigit(sender: UIButton)
{
if let digit = sender.currentTitle {
if userIsInTheMiddleOfTyping == true {
if digit == "." && decimalUsed == true {
return //where does this return to?
} else if digit == "." && decimalUsed == false {
decimalUsed = true
}
let textCurrentlyInDisplay = display.text!
display.text = textCurrentlyInDisplay + digit
} else {
display.text = digit
}
userIsInTheMiddleOfTyping = true
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…