const
🔹 Summary
The const
keyword allows the creation of a non-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 non-reassignable variable.
🔍 Syntax
const datatype name = value,
- Where datatype is
str
,int
, orbool
. - Where name is a combination of characters that contains letters and/or numbers. Name must unique, must have never been used as a variable name before.
- Where value can be a string literal, variable name (identifier), a number or a mathematical expression. (Expression can also utilize multiple variables.)
Examples:
const int a = 42,
const str b = "Hello world!",
const int c = 2 * 8,
shout a,
shout b,
shout a + c,
Output:
42
Hello world!
58