Skip to content

Commit ebeb708

Browse files
committed
[add] examples of conditionals.
1 parent 2f6810a commit ebeb708

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ This language is still currently experimental with many more features to come.
1818
* [Inheritance](examples/extends.ls).
1919
* [Functions](examples/func.ls).
2020
* [Variables](examples/variable.ls).
21-
* Conditionals.
21+
* [Conditionals](examples/conditionals.ls).
22+
* Logical operators.
2223
* Loops.
2324
* Closures.
2425
* [Recursion](examples/recursion.ls).

examples/conditionals.ls

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var x = true;
2+
3+
// Your typical if/else statement.
4+
if (x) {
5+
print "x is true";
6+
} else {
7+
print "x is false";
8+
}
9+
10+
11+
var num = 10;
12+
13+
// If/else if statements can be chained together too!
14+
if (num < 5) {
15+
print "num is less than 5";
16+
} else if (num < 8) {
17+
print "num is less than 8";
18+
} else if (num < 11) {
19+
print "num is less than 11";
20+
}

0 commit comments

Comments
 (0)