mercredi 1 juillet 2015

Short Circuiting vs Multiple if's

What are the differences between this:

if(a && b)
{
     //code
}

and this:

if(a)
{
     if(b)
     {
          //code
     }
}

From what I know b will only get evaluated in the first code block if a is true, and the second code block would be the same thing.

Are there any benefits of using one over the other? Code execution time? memory? etc.

Aucun commentaire:

Enregistrer un commentaire