# Gond 🚡 — `cond`-like multi-branch conditionals for Gleam
[](https://hex.pm/packages/gond)
[](https://www.erlang.org/)
[](https://en.wikipedia.org/wiki/JavaScript)
[](https://hexdocs.pm/gond/)
[](https://discord.gg/Fm8Pwmy)
[](https://github.com/inoas/gleam-gond/actions/workflows/test.yml)
<br>
<br>
<p align="center">
<i>
Think of a <a href="https://en.wikipedia.org/wiki/Gondola_lift">gondola lift 🚠</a> ride,
where you can hop off at any station.
</i>
</p>
<br>
## Installation
```sh
gleam add gond@2
```
## Examples
```gleam
import gleam/int
import gleam/io
import gleam/string
import gond.{
cond as cond, fact as fact, run as run, when as when, yield as yield,
}
pub fn example() {
cond(
branches: [
when(fn() { int.random(3) == 1 }) |> run(fn() { "Heads!" }),
fact(int.random(3) == 2) |> run(fn() { "Tails!" }),
when(fn() { True }) |> yield("This always occurs!"),
fact(False) |> yield("This is never the fact!"),
],
default: fn() { "Lost the coin?" },
)
}
pub fn main() {
example() |> string.inspect |> io.println
}
```
```shell
gleam run --module gond/internal/usage_examples
```
Further documentation can be found at <https://hexdocs.pm/gond>.
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
```
## Inspirations
- Clojure's [`cond` macro](https://clojuredocs.org/clojure.core/cond).
- Elixir's [`cond` macro](https://hexdocs.pm/elixir/case-cond-and-if.html#cond).