From 900bd3d64ac4c5c4c1511ab8388da3f2ed77849f Mon Sep 17 00:00:00 2001 From: Cody Date: Thu, 15 Dec 2022 14:18:13 -0600 Subject: Replace `let` keyword with `val` and `var` Thanks for pointing out that using `let` and `let mut` was stupid for a scripting language @mworzala --- tour/functions.sloth | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tour/functions.sloth') 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", -- cgit v1.2.3