This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Conditions
Oussama Essamadi edited this page Mar 24, 2024
·
2 revisions
LangKama supports conditionals for executing code based on Boolean conditions. This section describes how to use big if true
(if
), jk
(else if
), and sike
(else
) statements, along with the handling of common syntax errors.
Use the big if true
keyword to start an if statement, followed by a condition in parentheses. If the condition evaluates to true, the code block inside curly braces {}
is executed.
a sa7 hear me out a is 10.
hear me out value is L.
big if true (a > 20) {
bs will never reach this scope
value is W.
}
reda value. bs Outputs false because a is not greater than 20
LangKama allows for an else block (sike
) that executes when the if condition is false.
a sa7 hear me out age is 21.
a sa7 hear me out entryAge is 18.
hear me out value is L.
big if true (age > entryAge) {
value is W.
} sike {
value is L.
}
reda value. bs Outputs true because age is greater than entryAge
LangKama supports jk
for else if scenarios, allowing for multiple conditions to be evaluated in sequence.
a sa7 hear me out age is 21.
a sa7 hear me out entryAge is 18.
hear me out value is L.
big if true (age = entryAge) {
value is 50.
} jk (age > entryAge) {
value is 100.
} sike {
value is 0.
}
reda value. bs Outputs 100 because age is greater than entryAge
LangKama requires an open brace {
after the condition. Missing it results in a syntax error.
big if true(W)
loncina("this should not be reached").
}
bs This will raise an ExpectedOpenBraceError due to the missing "{"