Multi-branch conditional expression similar to if/else-if/else or cond for Gleam.
Think of a gondola lift ride,
where you can hop off at any station.
gleam add gond@2import gleam/int
import gond.{cond, fact, run, when, yield}
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() {
echo example()
}git clone https://github.com/inoas/gleam-gond.git
bin/run-examplesFurther documentation can be found at https://hexdocs.pm/gond.
gleam run # Run the project
gleam test # Run the tests- Clojure's
condmacro. - Elixir's
condmacro.
condifelseif/elseif/else/else ifif/else/elseifelse ifelseifelsifif statement
