Skip to content

Commit

Permalink
docs(if): add documentation for if/elif/else
Browse files Browse the repository at this point in the history
Signed-off-by: Flipez <code@brauser.io>
  • Loading branch information
Flipez committed Nov 27, 2023
1 parent 87fbfd2 commit 6e28eff
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions docs/docs/control_expressions/if.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
---
title: "If"
title: "If / elif / else"
menu:
docs:
parent: "controls"
---
import CodeBlockSimple from '@site/components/CodeBlockSimple'

# If
With `if` and `else` keywords the flow of a program can be controlled.

```js
🚀 > if (a.type() == "STRING")
puts("is a string")
<CodeBlockSimple input='if (a.type() == "STRING")
puts("is a string")
else
puts("is not a string")
end
puts("is not a string")
end' output='is a string' />

# Elif
`elif` allows providing of an additional consequence check after `if` and before evaluating the alternative provided by `else`. There is no limit on how many `elif` statements can be used.

// which prints
is a string
```
<CodeBlockSimple input='if (a.type() == "BOOLEAN")
puts("is a boolean")
elif (a.type() == "STRING")
puts("is a string")
else
puts("i have no idea")' output='is a string' />

0 comments on commit 6e28eff

Please sign in to comment.