From 156a6533d8ac498d6f5f5d6c035f2e5b55f525ee Mon Sep 17 00:00:00 2001 From: Amir Saboury Date: Tue, 9 Jul 2024 14:46:42 -0400 Subject: [PATCH 1/2] add support if/else statements --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 582bff82c..f811671b0 100644 --- a/README.md +++ b/README.md @@ -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): From 93c5e794ada59e257625f76592856cccc0fd13a4 Mon Sep 17 00:00:00 2001 From: Amir Saboury Date: Tue, 9 Jul 2024 14:47:02 -0400 Subject: [PATCH 2/2] add my thing to the thing --- docs/contributors/readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/contributors/readme.md b/docs/contributors/readme.md index 9799cdd00..ddd2e83e4 100644 --- a/docs/contributors/readme.md +++ b/docs/contributors/readme.md @@ -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 🚀