Skip to content

๐Ÿšก multi-branch conditional expression similar to if/else-if/else or cond for Gleam ๐Ÿš 

License

Notifications You must be signed in to change notification settings

inoas/gleam-gond

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

49 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšก Gond ๐Ÿš 

Package <a href="https://github.com/inoas/gleam-gond/releases"><img src="https://img.shields.io/github/release/inoas/gleam-gond" alt="GitHub release"></a> Version Erlang-compatible JavaScript Compatible Hex Docs Discord CI Test

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.

Installation

gleam add gond@2

Examples

import 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()
}

Run usage examples

git clone https://github.com/inoas/gleam-gond.git
bin/run-examples

Further documentation can be found at https://hexdocs.pm/gond.

Development

gleam run   # Run the project
gleam test  # Run the tests

Inspirations

Tags

  • elseif
  • elsif
  • if statement

About

๐Ÿšก multi-branch conditional expression similar to if/else-if/else or cond for Gleam ๐Ÿš 

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •