Is it bad practice to not follow an if-statement with an else-statement? Is it purely preference, or are there standards (such as for readability, or sustainability, etc..) that encourage complete if-else statements?
Recently i found myself using more if-statements without an else, but its for code that will break/return, such as
if(x == y) return z;
//otherwise do the rest of the code below
as opposed to
if(x==y){
return z;
}
else{
//execute code
}
Does it make any difference for the compiler if i do if-else or just an if?
Aucun commentaire:
Enregistrer un commentaire