jeudi 7 juillet 2016

Why can't i check the return of a function with a switch?

With if statements it is possible to check the return of an integer function. The function gets executed within this.

if(!yourfunction)
{
     do something;
}
else
{
     do something else;
}

The very same thing in switch however, won't even execute the function. Why?

switch(yourfunction())
{
      case 1:
            do something;
      case 0:
            something else;
}

Aucun commentaire:

Enregistrer un commentaire