Home Explore Blog CI



nushell

lang-guide/chapters/types/basic_types/bool.md
7f9165a9a20d9a5fca9e82f79653c26f0a7fe9ff0c2367d1000000030000050f
# Boolean

|                       |                                                             |
| --------------------- | ----------------------------------------------------------- |
| **_Description:_**    | A logical data type that can have only True or False values |
| **_Annotation:_**     | `bool`                                                      |
| **_Literal syntax:_** | Either a literal `true` or `false`                          |
| **_Casts:_**          | [`into bool`](/commands/docs/into_bool.md)                  |
| **_See also:_**       | [Types of Data - Booleans](/book/types_of_data.md#booleans) |

## Common commands that can be used with `bool`

- `if`, `while`
- `match` (in clauses where the expression matches the clause expression, or the `_` value which is always true)

- `is-empty`, `is-not-empty`
- `is-admin`
- `is-terminal`

The following commands take a closure as their main argument. The return value from the closure must be a boolean:

- `where`/`filter`
- `any`, `all`, `skip until`, `skip while`, `take until`, `take while`

## Common operators that can be used with `bool`

- `==`, `!=`, `<`, `<=`, `>`, `>=`
- `and`, `or`, `not`
- `in`
- Regex comparison operators: `=~`, `!~` `<regex>`
- String comparison operators: `ends-with`, `starts-with`

Chunks
2da0abf4 (1st chunk of `lang-guide/chapters/types/basic_types/bool.md`)
Title: Boolean Data Type in Nushell
Summary
This section describes the boolean data type in Nushell, which can have either `True` or `False` values. It details the annotation (`bool`), literal syntax (`true` or `false`), and casting methods. It also lists common commands and operators that can be used with boolean values, including control flow commands, comparison operators, logical operators, and commands that accept closures returning booleans.