I am curious, for the codes blow:
Code 1:
var myValue = 10;
if(isBlocked)
myValue = 20;
Code 2:
var myValue;
if(isBlocked)
myValue = 20;
else
myValue = 10;
Both should do the same thing. But I prefer Code 1, as it obviously requires less lines. Is it better to use Code 1 for single value assignment?
Aucun commentaire:
Enregistrer un commentaire