You can use the logical operator OR
to check if a condition is true for any of the given cases using an if
statement.
Here is an example code block:
main.m82 chars5 lines
In this example, the OR
operator is used to check if x
is equal to 1, 2, or 3. If x
is equal to any of these values, then the corresponding message will be displayed.
You can also use the OR
operator to check for multiple conditions. For example:
main.m121 chars6 lines
In this example, the OR
operator is used to check if either x
is equal to 1 or 2, or y
is equal to 4 or 5. If any of these conditions are met, then the corresponding message will be displayed.
gistlibby LogSnag