I've got this (example) code:
if (condition1) {
do_something();
return;
}
if (condition2) {
if (do_stuff())
return;
}
if (condition3) {
do_anotherthing();
return;
}
// 10 more conditions
do_stuff sets one of the conditions, say condition8, if it returns true. I'd like to shorten this code by writing else if and removing the returns. But I don't know how to do this, since it should only continue checking if do_stuff returns true. What sholud I do?
Aucun commentaire:
Enregistrer un commentaire