I'm quite new to coding and I've never understood what's the proper way to do the following:
if (something == true) {
DoSomething();
} else {
if (something2 == true) {
DoSomething2();
}
DoSomethingAnyways();
}
I've heard using else if is the right way to do this, but how can I execute the DoSomethingAnyways(); if I use else if?
Basically what I'm asking is how can I write this using else if and have the exact same effect?
if (something == true) {
DoSomething();
} else if (something2 == true) {
DoSomething2();
DoSomethingAnyways(); //<-- Where do I put this line of code?
}
Aucun commentaire:
Enregistrer un commentaire