display.text = newValue != nil ? \"\\(newValue!)\" : \" \"
Does the syntax of the code mean, let display.text = newValue, if it does not equal nil
From the documentation
Ternary Conditional Operator
The ternary conditional operator is a special operator with three parts, which takes the form
question ? answer1 : answer2
. It is a shortcut for evaluating one of two expressions based on whether question is true or false. If question is true, it evaluatesanswer1
and returns its value; otherwise, it evaluatesanswer2
and returns its value.The ternary conditional operator is shorthand for the code below:
if question { answer1 } else { answer2 }