Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Conditions #705

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,49 @@ If you want to be much less precise, you can use `=`.
3 = 3.14! //true
```

## If-Else Statements

If-else statements are simple in DreamBerd. Any of the following are acceptable usage of if-else keywords:

1. `if`
2. `else if`
5. `else`
4. `elsif`
3. `els`
2. `ifelse`
1. `ifelsif`
2. `ifels`
3. `ifelse`
42. `ifelse if`
420. `if else`
68. `if else if`
69. `if els`
69. `if els if`
69. `if els`
5. `if els`

Note that there is technically no `else` in DreamBerd. `else` is just syntax sugar for `elseif` statement. This makes conditions more explicit and easier to read as you have to describe the condition in the `else` statement.

```java
const var health = 10!
if (health = 0) {
print("You're dead")!
} else (health != 0) {
print("You're healthy")!
}
```

This also enables you to have `if` statements in any order.

```java
const var wealth = 10!
else (wealth != 0) {
print("You're wealthy")!
} if (wealth = 0) {
print("You're poor")!
}
```

## Functions

To declare a function, you can use any letters from the word `function` (as long as they're in order):
Expand Down
1 change: 1 addition & 0 deletions docs/contributors/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ This list is only for people who have had a pull request accepted. If that's you
- mrroiz
- ultragreed
- borderss
- MashMooshak 🚀