jeudi 11 octobre 2018

why do we rather check condition for false than for true

By reading many tutorials out here, I noticed that mostly, if a condition is checked, like in a if/else, people would rather check first if a condition is false than if it's true like

if(!condition){

 //stop what you're trying

} else {

 //do what I want to be done

}

Anyone has a good explanation?

ps: I asked this question without a specific programming language declaration as I saw this practise in many different languages

Aucun commentaire:

Enregistrer un commentaire