samedi 28 novembre 2015

What is called if 2 bools are true in if/else statements

In a normal if/else statement if one bool, for example, is true it calls that statement e.g:

bool1 = true;
bool2 = false;
bool3 = false;

if(bool1){
    DoSomething();
}else if(bool2){
    DoSomethingElse();
}else{
    DoSomethingHelpful();
}

Of course, in this example DoSomething() will be called.

But what if 2 or 3 of the bools were equal to true, e.g:

bool1 = true;
bool2 = true;
bool3 = false;

if(bool1){
    DoSomething();
}else if(bool2){
    DoSomethingElse();
}else{
    DoSomethingHelpful();
}

What statement will be called? Would it be DoSomething() because its the first statement read by the compiler?Or would it just return with an error

Aucun commentaire:

Enregistrer un commentaire