-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from Flipez/implement-elseif
Implement `if / elif / else`
- Loading branch information
Showing
18 changed files
with
142 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
--- | ||
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='a="test" | ||
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='a = "test" | ||
if (a.type() == "BOOLEAN") | ||
puts("is a boolean") | ||
elif (a.type() == "STRING") | ||
puts("is a string") | ||
else | ||
puts("i have no idea") | ||
end' output='is a string' /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"single if" | ||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (true) | ||
puts("single if") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"if/elif: if block" | ||
"if/elif: elif block" | ||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
i = 0 | ||
while (i<2) | ||
if (i==0) | ||
puts("if/elif: if block") | ||
elif (i==1) | ||
puts("if/elif: elif block") | ||
end | ||
|
||
i = i+1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"if/elif/el: if block" | ||
"if/elif/elif/el: first elif block" | ||
"if/elif/elif/el: second elif block" | ||
"if/elif/else: else block" | ||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
i = 0 | ||
while (i<4) | ||
if (i==0) | ||
puts("if/elif/el: if block") | ||
elif (i==1) | ||
puts("if/elif/elif/el: first elif block") | ||
elif (i==2) | ||
puts("if/elif/elif/el: second elif block") | ||
else | ||
puts("if/elif/else: else block") | ||
end | ||
|
||
i = i+1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"if/elif/el: if block" | ||
"if/elif/el: elif block" | ||
"if/elif/el: else block" | ||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
i = 0 | ||
while (i<3) | ||
if (i==0) | ||
puts("if/elif/el: if block") | ||
elif (i==1) | ||
puts("if/elif/el: elif block") | ||
else | ||
puts("if/elif/el: else block") | ||
end | ||
|
||
i = i+1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"if/else: if block" | ||
"if/else: else block" | ||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
i = 0 | ||
while (i<2) | ||
if (i==0) | ||
puts("if/else: if block") | ||
else | ||
puts("if/else: else block") | ||
end | ||
|
||
i = i+1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2c802b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rocket-lang-play – ./wasm
rocket-lang-play-git-main-flipez.vercel.app
rocket-lang-play.vercel.app
play.rocket-lang.org
rocket-lang-play-flipez.vercel.app
2c802b9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rocket-lang – ./docs
rocket-lang.org
rocket-lang-flipez.vercel.app
rocket-lang.vercel.app
rocket-lang-git-main-flipez.vercel.app
www.rocket-lang.org