+ 1

Question about --i

Could you explain me why the else branch is executed? Thank you😊 https://code.sololearn.com/wc3IfCNqTuaS/?ref=app

19th Dec 2018, 9:11 PM
Eleonora
5 Answers
+ 1
Here is preicrement operator "--i". The value of i is decreased by 1. The value of i now is 0. In the if clause it's 0 == (0 + 1) => false. So the else condition is executed.
19th Dec 2018, 9:18 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
You are welcome 😉
19th Dec 2018, 9:28 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
So the equality is evaluated after the decrementation?
19th Dec 2018, 9:23 PM
Eleonora
0
Yes, that is right. You can find more info about this here https://www.sololearn.com/learn/PHP/1803/
19th Dec 2018, 9:26 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
Thank you 😊
19th Dec 2018, 9:27 PM
Eleonora