# boolean · Rell standard library · Chromia Docs (concept)

> type boolean A data type with two possible values: true and false . Boolean logic can be performed with the and , or and not operators, for example: Rell C

Source: https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/boolean/

TYPE

# boolean

```signature
type boolean
```

A data type with two possible values: `true` and `false`.

Boolean logic can be performed with the `and`, `or` and `not` operators, for example:

Rell

```
>>> true and false
false
>>> true or false
true
>>> not true
false
>>> not false
true
```

In addition, booleans are used in ternary expressions:

Rell

```
>>> if (true) 1 else 2
1
>>> if (false) 1 else 2
2
```

The `in` operator returns a boolean:

Rell

```
>>> 1 in list<integer>()
false
>>> 1 in [1, 2]
true
```

Booleans are used in `if`- and `if/else`-statements:

Rell

```
>>> if (false) { print("hello"); } else { print("goodbye"); }
goodbye
>>> if (false) { print("hello"); }
>>> if (true) { print("hello"); }
hello
>>>
```

Boolean expressions are the basis of zero-argument `when`-statements (each expression to the left of a
'`->`' symbol has boolean type (and in this context `else` is equivalent to `true`)):

Rell

```
when {
    x == 1 -> return 'One';
    x >= 2 and x <= 7 -> return 'Several';
    x == 11, x == 111 -> return 'Magic number';
    some_value > 1000 -> return 'Special case';
    else -> return 'Unknown';
}
```

Boolean conditions are used in while loops:

Rell

```
while (x < 10) {
    print(x);
    x = x + 1;
}
```

Functions can have `boolean` return type (as can queries and operations), and indeed many functions and
properties in the Rell standard library have `boolean` type.

Rell

```
function foo(x: integer): boolean {
    return x >= 10;
}
```

Since 0.6.0

[View this page on docs.chromia.com](https://docs.chromia.com/pages/rell-stdlib/-rell%20-system%20-library/%5Broot%5D/boolean/index.html)Generated API reference, mirrored from the live docs
