if
❗By default, every variable is global, meaning every nested if statement will have the same variables as its parent. As of v0.1.1
there is no way to change this behaviour.
🔹 Summary
The if
keyword allows the creation of a conditional block of code that only runs if the condition it is assigned to evaluates to True
. This allows for use of much more complex logic as and when required.
TLDR: Allows creation of a block of code that only runs in a specific condition.
🔍 Syntax
if (name comparison_op block1) ( block2 ),
- Where name is an identifier that contains a value of the datatype
str
,num
, orbool
. - Where comparison_op is one of the two comparison operators available.
- Where block1 is a
str
,bool
, or either a mathematical expression (with variables) or anum
, corresponding to the datatype field ofname
. - Where block2 is a block of Lamentable code which can contain anything, just like the base. Nested if statements are allowed.
Examples:
const int a = 45,
if (a == 40 + 5)
(
shout "a = 40 + 5",
),
const bool b = True,
if (b != False)
(
shout "b is True",
)
const str c = "Hello world!",
if (c == "Hello world!"),
(
shout c,
)
Output:
a = 40 + 5
b is True
Hello world!