diff options
| author | Cody <cody@codyq.dev> | 2022-12-15 14:18:13 -0600 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2022-12-15 14:18:13 -0600 |
| commit | 900bd3d64ac4c5c4c1511ab8388da3f2ed77849f (patch) | |
| tree | 8de3006843d9dc717bf1c00d9942a068c90f413c /tour/functions.sloth | |
| parent | bddb011df4999f7ffeeddf6a4b66e2da6ab19ea0 (diff) | |
| download | sloth-900bd3d64ac4c5c4c1511ab8388da3f2ed77849f.tar.gz | |
Replace `let` keyword with `val` and `var`
Thanks for pointing out that using `let` and `let mut` was stupid for a
scripting language @mworzala
Diffstat (limited to 'tour/functions.sloth')
| -rw-r--r-- | tour/functions.sloth | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tour/functions.sloth b/tour/functions.sloth index e6c8b89..529d108 100644 --- a/tour/functions.sloth +++ b/tour/functions.sloth @@ -1,13 +1,13 @@ # Types can be inferred. # If inferrence fails it will be set to "any" unless strict mode is on pub fn add(lhs, rhs) { - let result = lhs + rhs; + val result = lhs + rhs; return result; } # ...or manually specified pub fn mul(lhs: i32, rhs: i32) -> i32 { - let result = lhs * rhs; + val result = lhs * rhs; return result; } @@ -16,14 +16,14 @@ pub fn mul(lhs: i32, rhs: i32) -> i32 { ## lhs: Left hand side of subtraction ## rhs: Right hand side of subtraction pub fn sub(lhs: i32, rhs: i32) -> i32 { - let result = lhs - rhs; + val result = lhs - rhs; return result; } ## Fizzbuzz implementation from 1 through 100 fn fizzbuzz() { for x in 1..=100 { - let message = match (x % 5, x % 3) { + val message = match (x % 5, x % 3) { (0, 0) => "FizzBuzz", (0, _) => "Fizz", (_, 0) => "Buzz", |
