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 6e28eff commit 5c308df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/docs/control_expressions/if.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import CodeBlockSimple from '@site/components/CodeBlockSimple'
# If
With `if` and `else` keywords the flow of a program can be controlled.

<CodeBlockSimple input='if (a.type() == "STRING")
<CodeBlockSimple input='a="test"
if (a.type() == "STRING")
puts("is a string")
else
puts("is not a string")
Expand All @@ -18,9 +19,11 @@ 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.

<CodeBlockSimple input='if (a.type() == "BOOLEAN")
<CodeBlockSimple input='a = "test"
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' />
puts("i have no idea")
end' output='is a string' />

0 comments on commit 5c308df

Please sign in to comment.