Skip to content

Commit

Permalink
if/else options
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Mar 27, 2020
1 parent 2613c3d commit 37c7bed
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions if_else.gleam
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// # 1: C style
fn one() {
if is_ok() {
it_is_ok()
Expand All @@ -6,12 +7,78 @@ fn one() {
} else {
whatever()
}

if is_ok() {
go_one()
go_two()
} else if is_alright() {
go()
} else {
whatever()
}

if is_ok() {
it_is_ok()
}

if is_ok() { it_is_ok() }

if is_ok() {
go_one()
go_two()
}
}

// # 2: case similar style, braces required
fn two() {
if {
is_ok() -> it_is_ok()
is_alright() -> go()
else -> whatever()
}

if {
is_ok() -> {
go_one()
go_two()
}
is_alright() -> go()
else -> whatever()
}

if {
is_ok() -> it_is_ok()
}

if {
is_ok() -> {
go_one()
go_two()
}
}
}

// # 3: case similar style, braces optional
fn three() {
if {
is_ok() -> it_is_ok()
is_alright() -> go()
else -> whatever()
}

if {
is_ok() -> {
go_one()
go_two()
}
is_alright() -> go()
else -> whatever()
}

if is_ok() -> it_is_ok()

if is_ok() -> {
go_one()
go_two()
}
}

0 comments on commit 37c7bed

Please sign in to comment.