Used when comparing values. The writing style seems to be similar to what I learned in mathematics, but it is slightly different. Some of the comparison operators are described below.
Comparison operator | Conditional expression | meaning |
---|---|---|
> | A > B | Is A greater than B? |
>= | A >= B | Is A more than B? |
< | A < B | Is A smaller than B? |
<= | A <= B | Is A less than or equal to B? |
== | A == B | Are A and B equal? |
The boolean value indicates whether the expression is correct or different. True if the value is true False if the value is false It is represented by.
Operators that can check the authenticity of expressions and perform operations on boolean values are called logical operators.
When used with boolean values, it returns true if either of the operations is true, or false if both are false. A || B (Image like A or B)
When used with booleans, it returns true if both of the operations are true, false otherwise. A && B (image like A and B)
The! (Exclamation mark) is called the not operator and is used to mean negation. ! =, which is a combination of! And =, returns true if the values are not equal.
A! = B (A and B are not equal)
If it is 〇〇, it is a thing that branches the process depending on the condition like □□
if conditional expression # Processing is executed when this conditional expression is true
processing
end
if conditional expression
#Conditional expression is true(true)Processing to be executed at
else
#Conditional expression is false(false)Processing to be executed at
end
if conditional expression 1
#Conditional expression 1 is true(true)Processing to be executed at
elsif conditional expression 2
#Conditional expression 1 is false(false)At that time
#Conditional expression 2 is true(true)Processing to be executed at
else
#Both conditional expression 1 and conditional expression 2 are false(false)Processing to be executed at
end
that's all.
Recommended Posts