Equivalence and relational operators test or define the type of relationship between two entities to generate a truth number. This can be used in several cases where we need to validate data, algorithms, and other cases.
Cheat / Cheat Sheet
> | Greater than |
< | Smaller than |
>= | Greater or equal to |
<= | Smaller than or equal to |
== |
Same as |
!= | Not the same as |
is | declares that the type is the same |
is! | declares that the types are not equal |
Explain & Practice
Greater than (>)
Operators (>)
Example case 6>5 result is true ( true).
Code example
void main() {
print(6>5);
}
The result is
true
Smaller than (<)
Operators (<)
Example case 6<5 the result is true ( false).
Code example
void main() {
print(6<5);
}
The result is
false
Greater or equal to (>=)
Operators (>=)
Example case 6>=5 result is (true)
code example
void main() {
print(6>=5);
}
The result is
true
Example of the 2nd case:
5 >= 5 the result is (true)
code sample
void main() {
print(5>=5);
}
The result is
true
Smaller than or equal to (<=)
Operators (<=)
Example case 6<=5 the result is (false)
code example
void main() {
print(6<=5);
}
The result is
false
Example of the 2nd case:
5 <= 5 the result is (true)
code sample
void main() {
print(5<=5);
}
The result is
true
Same as (==)
operator (==)
Example:
divine == goddess result is (false)
code example
void main() {
print("virtue"=="goddess");
}
The result is
false
Not the same as (!=)
operators (!=)
Example:
budi != goddess result is (true)
code example
void main() {
print("virtuous"!="goddess");
}
The result is
true
Is
operator (is)
Example:
0.1 is int result is ( false)
code example
void main() {
print(0.1 is int);
}
The result is
false
Is not (is!)
operator (is!)
Example:
0.1 is not int the result is ( true)
code example
void main() {
print(0.1 is! int);
}
The result is
true