0

Why is the answer 2 1 1 ?

Which choice is the output value of the following code: var a = 0 let b = ++a let c = a++ print("\(a) \(b) \(c)") Why does \(a) = 2 ?

9th Sep 2016, 8:26 AM
Hannah
1 Resposta
+ 4
Because it has been incremented twice (first time with ++a, second time with a++). a++ doesn't mean that the incrementation isn't done, just that the value of a is used before the incrementation.
14th Sep 2016, 11:00 AM
Zen
Zen - avatar