Skip to content

Commit

Permalink
Add relational operator examples for non-numeric types
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed Sep 27, 2024
1 parent 3d3d419 commit a98324b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/binary-operators/binary_operators.bal
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function main() {
int remainder = b % a;
io:println(remainder);

// `>`, `<`, `>=` and `<=` are use to perform the relative order of two values.
// Check if `a` is less than `b`.
boolean isLessThan = a < b;
io:println(isLessThan);
Expand Down Expand Up @@ -70,6 +71,10 @@ public function main() {
boolean logicalOr = c || d;
io:println(logicalOr);

// `false` is considered less than `true`.
boolean isLessThanBoolean = d < c;
io:println(isLessThanBoolean);

int g = 10;
int h = 20;

Expand Down Expand Up @@ -103,4 +108,8 @@ public function main() {
// Concatenate two strings.
string concatenatedString = i + " " + j;
io:println(concatenatedString);

// Check if `i` is lexicographically greater than `y` in Unicode code point order.
boolean isGreaterThanString = i > j;
io:println(isGreaterThanString);
}
2 changes: 2 additions & 0 deletions examples/binary-operators/binary_operators.out
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ true
false
false
true
true
0
30
30
40
2
2
Hello Ballerina
true

0 comments on commit a98324b

Please sign in to comment.