-
Notifications
You must be signed in to change notification settings - Fork 3
If & else
Pikt handles conditions the traditional way via if 
else 
else if 
if <condition> <block>
else if <condition> <block>
else <block>
Where <condition> can be any kind of expression.
If it is a boolean expression, the condition is true only if the boolean is true. Otherwise the condition is true if the given expression is not null, but we will learn about nullable values later.
<block> contains the code to be executed if the condition is satisfied.
It can be either a single action, such as a print, a function call or a variable update, or a more complex block. In that case, it has to be surrounded by lambda.open 
lambda.close 
Pseudocode:
if (true) {
print("OK")
} else {
print("NO")
}Pikt (remember that true is represented by bool.true 
But, since print is a single action, we can remove lambda.open 
lambda.close 
Pikt offers a standard set of logical and relational operators to build boolean expressions:
-
op.and(&&) -
op.or(||) -
op.equality(==) -
op.inequality(!=) -
op.greater(>) -
op.greater_or_equals(>=) -
op.less(<) -
op.less_or_equals(>=)
Like many programming languages, operators must be put between two values.
Pseudocode:
var my_var = 1
if (my_var == 1) {
print("OK")
} else if (true && false) {
print("NO")
}Pikt (remember that false is represented by bool.false 


