Skip to main content

Booleans

Muhammad FurqanLess than 1 minute

Introduction

A boolean is a value that can be either True or False. They are quite useful and are used all the time in programming. A variable can be a boolean.

You should try to name your booleans (variables and functions) positively. It makes it harder to misunderstand their meaning and get them wrong.

Wrong names: playerDead, invoicePaid, userNotExists()

Correct names: playerAlive, invoicePaid, userExists()