# Boolean

## Logic

`Boolean → Object`

Boolean values.

Example:

```True
False```
```a && b → in?: [True, False]
| a is-a?: Boolean
| b is-a?: Boolean```

Test whether `a` and `b` are both `True`. This is actually a macro which calls the short-circuiting `and:`.

Example:

```> True && False
False
> (1 == 1) && (\$a /= \$b)
True
```
```a || b → in?: [True, False]
| a is-a?: Boolean
| b is-a?: Boolean```

Test if either `a` or `b` are `True`. This is actually a macro which calls the short-circuiting `or:`.

Example:

```> True || False
True
> (1 == 1) || (\$a /= \$b)
True
```
```a and: b → in?: [True, False]
| a is-a?: Boolean
| b is-a?: Block```

A short-circuiting form of `&&`, only `call`ing the right-hand side if `a` is `True`.

```a or: b → in?: [True, False]
| a is-a?: Boolean
| b is-a?: Block```

A short-circuiting form of `||`, only `call`ing the right-hand side if `a` is `False`.

```a not → in?: [True, False]
| a is-a?: Boolean```

Negate `a`.

Example:

```> True not
False
> False not
True
> True not not
True
```

## Control Flow

```if: test then: yes else: no → any
| test is-a?: Boolean
| yes is-a?: Block
| no is-a?: Block```

Basic if-then-else control flow. If `test` is `True`, `yes` is `call`ed, otherwise `no` is. The result is the result of whichever block is called.

Example:

```> if: (1 == 0) then: { "Uh-oh." } else: { "We're good!" }
"We're good!"
```
```when: test do: action → @ok
| test is-a?: Boolean
| action is-a?: Block```

Sends `call` to `action in-context` if `test` is `True`, always returning `@ok`.

Example:

```> a = 0
0
> b := when: (a == 1) do: { "a is 1!" print }
@ok
> b
@ok
> a = 1
1
> b
a is 1!
@ok
```
```while: test do: action → @ok
| test is-a?: Block
| action is-a?: Block```

Continually sends `call` to `action in-context` until `test` yields `False`.

Example:

```> a = 1
1
> while: { a < 10 } do: { a = a + 1 }
@ok
> a
10
```
```condition: branches → any
| branches is-a?: Block```

Similar to Scheme's `cond`, this construct takes a block pairing tests with their branch, and goes through each pairing until a test yields `True`, in which case it evaluates the expression that test was associated with.

If no branches yield `True`, `@no-true-branches` is raised.

NOTE: This is a macro which expands to chained `if:then:else:` dispatches.

Example:

```> condition: { False -> "Hello!" print; True -> "Goodbye!" print }
Goodbye!
"Goodbye!"
> condition: { 1 == 1 -> 0; otherwise -> 1 }
0
```
`otherwise → True`

Alias for `True` for use in `condition:`, or anywhere else where it would look nicer.