let
🔹 Summary
The let
keyword allows the creation of a reassignable variable with the datatype str
, int
or bool
. The value stored in the variable can be retrieved at any time using the name of the variable.
TLDR: Creates a reassignable variable.
🔍 Syntax
let datatype name = value,
- Where datatype is
str
,int
orbool
. - Where name is a combination of characters that contains letters and/or numbers.
- Where value can be a string literal, variable name (identifier), a number or a mathematical expression. (Expression can also utilize multiple variables.)
Examples:
let int a = 1,
let int b = 3 * 5,
let str c = "Hello world!",
shout a,
shout b,
shout a + b,
shout c,
Output:
1
15
16
Hello world!