Dictionary entry
bool
Last updated
Meanings
nouncountablecomputing
In programming, a value or variable that can be only true or false.
Grammar: Countable: a bool, two bools; often written as a type name in code, e.g. bool flag.
Patterns
- a bool variable
- set something to a bool
- return a bool
The function returns a bool: true if the file exists, false if it does not.
Declare the flag as a bool so it can only be true or false.
Beginners often forget that a bool cannot hold a number or a word.
noununcountablecomputing
A data type in a programming language whose values are true and false.
Grammar: Uncountable when naming the type itself: convert the text to bool.
Patterns
- convert something to bool
- store something as bool
In Python, bool is a built-in type, so you do not need to import it.
The compiler treats the result as bool, not as an integer.
Word forms
| plural | bools |
|---|
Common combinations
- a bool value
- Each setting is stored as a bool value, either true or false.
- return a bool
- Write a helper method that returns a bool.
- convert to bool
- The parser will convert the input to bool before comparing.
- bool variable
- Name the bool variable isReady so the code reads clearly.
Synonyms and how they differ
- Boolean
- The standard adjective and noun form; use Boolean in formal writing and bool mainly in code or technical talk.
- flag
- A flag is a variable that marks whether something is on or off; it is usually a bool but the word describes its job, not its type.
Word family
- Boolean adjective
- Relating to true-or-false logic, as in Boolean algebra or a Boolean search.
Commonly confused: bool or boolean? bool or boule?
bool vs boolean
Same idea, different spelling and use: Boolean is the normal word in English text, while bool is the short form used inside programming languages.
bool vs boule
Sounds similar but means a ball, especially in the French game of boules, or a shape of cut gem.
Practice
Which sentence uses "bool" correctly?
Choose one answer.
A bool is a true-or-false value in computing, so storing a choice as a bool fits. Option 1 confuses it with boil, option 3 would need the adjective Boolean, and option 4 invents a verb.
Make it your own
Write a sentence using “bool”, then check it and compare it with the examples above.