+ 1

i dont understand the answer again please help

Question is var a = 0 let b = ++a let c = a++ Print("\(a) \(b) \(c)") I know let b and let c the different is 0+1 and 1+0 But i don't understand why var a will convert to 2 Is it b plus c? so var a = b plus c ? Thanks guys for help

26th Jul 2017, 7:53 AM
Leung Julius
Leung Julius - avatar
1 Odpowiedź
+ 1
a=0 b = ++a writing this you are saying that you want to increment a (a becomes 0+1=1) and then assign his value to b (b becomes 1) c = a++ here you are first assigning to c the value of a (c becomes 1) and then incrementing a (a becomes 2) so at the end you have a=2, b=1, c=1
26th Jul 2017, 8:58 AM
Matte
Matte - avatar