This document describes how to implement if conditional statements, logic, and comparison operations in block coding.
Index
Conditional statement
•
A conditional statement is a statement that performs a calculation or response that depends on the result of a given conditional expression.
1) Logic - if / Logic, Comparison Operation Blockset
•
A blockset that implements conditional statements by combining if statements, logic, and comparison operational blocks.
•
Click the button to add or delete conditions in logical comparison form (&&, ||)
•
Write the logic to act when the result of the condition is true in the area below.
2) elseif
•
A case where the result of the if statement is not true is verified by adding a condition to the else if block.
•
Click the button to add or delete conditions in logical comparison form (&&, ||)
•
Write the logic to act when the result of the condition is true in the area below.
3) else
•
Write the logic in the area below to act if all conditions of the if statement and else if statement are false.
Logical / Comparison Operations Block
•
Logical / comparison operation statement is operation statement that returns true or false by a certain operation.
1) Comparison Operations
•
Put a block that can be compared to the left and right of the operation symbol and return the result (true / false) after operation.
Comparison symbol | Explanation |
=== | Equal |
!== | Not equal |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
2) Logic / Comparison operation
•
In the if, elseif conditional block, add a condition with the button.
•
Returns the result (true / false) of the entire conditional statement through logical symbols.
Logic symbol | Explanation |
&& | and |
|| | or |
•
Below is an example using the if conditional statement and logical / comparison operation statement.