I wonder why equality operator doesn't work as intended in the following piece of code:
if(number_of_coins==(1 || 2 || 3))
Does the equality sign compares number_of_coins with the last value (3) only? I can instead use the code below, but writing it is time consuming in some cases:
if(number_of_coins==1 || number_of_coins==2 || number_of_coins==3)
If switch statement was returning value, it would be useful in this case. Any advice?
Aucun commentaire:
Enregistrer un commentaire