Post

Replies

Boosts

Views

Activity

Not expected result when changing a variable in a "defer" block, if the variable has observers willSet or didSet.
Why is the result 3? Is this the correct behavior? func foo() {   var i = 0 {     willSet {}   }       defer {     i -= 1     print(i) // expected result - 2, prints - 3   }       i = 3 }
Replies
4
Boosts
0
Views
433
Activity
Oct ’21