jeudi 7 février 2019

If-else vs if not-if

According to a lead at work, the distinction between

if (invalid) {
   ...some code
}

if (!invalid) {
  ...some code
}

and

if (invalid) {
  ...some code
} else {
  ...some code
}

is merely a style choice. Not something that is considered bad practice. I was wondering where people draw the line and what you would consider this.

PS: Yes, I know negations should not be the 'nominal' case for if statements. Please ignore that as I was trying to replicate exactly the code in question that prompted the discussion.

Aucun commentaire:

Enregistrer un commentaire