Additional chain used on the left side of the job in Swift

What does this mean when an extra chain is used on the left side of the assignment operator? Is the application damaged if the optional variable is zero?

eg.

// cell is a UITableViewCell
cell.textLabel?.text = "Test"
+2
source share
3 answers

As a short-circuit operator &&that stops when it reaches the first false value, the extra chain stops when it reaches the first nil value.

, , container?.cell?.textLabel?.text = "foo", , textLabel . - , . , .

+3

, @gregheo :

, . nil, .

+2

It will act as optional, you can set it as a string or zero. None of them will cause the application to crash if you do not expand your variable without catching if it is zero when it is zero. If anything in your chain is optional, your whole chain (or at least everything after the optional)

0
source

Source: https://habr.com/ru/post/1677244/


All Articles