lundi 8 juillet 2019

Why there's a not operator in programming?

Regardless of the programming language, Why there's a not operator while I may compare the expression with false and that will do the work needed.

For example, if I have a function called valid that returns boolean (true if valid and false if not) and I want to check if it's not valid then I will write it like this:

if not valid():
   print("Not Valid")


While I can simply check if valid equals false like this:

if valid() == false:
   print("Not Valid")


Aucun commentaire:

Enregistrer un commentaire