05Operators
Comparison
Ask whether values are equal, greater or less.
A comparison asks a true-or-false question about two values: are the two equal? Is
one bigger? The answer is a boolean, မှန် or မမှန်.
စံကား
Expected output
မှန်
မမှန်
မှန်
မှန်
မမှန်
မှန်
All six comparisons
| Sign | Words | Reads as |
|---|---|---|
a == b | a သည် b နှင့် ညီသည် | a is equal to b |
a != b | a သည် b နှင့် မညီပါ | a is not equal to b |
a > b | a သည် b ထက် ကြီးသည် | a is greater than b |
a <= b | a သည် b ထက် မကြီးပါ | a is not greater than b |
a < b | a သည် b အောက် ငယ်သည် | a is less than b |
a >= b | a သည် b အောက် မငယ်ပါ | a is not less than b |
The မ in front of a verb means "not": မညီ is "not equal", မကြီး is "not greater".
Equals uses = twice: ==. A single = is not an operator in Zaka.
စံကား
Expected output
မှန်
မှန်
မှန်
Characters can be compared too. Their order follows the Unicode number, so 'က'
comes before 'ခ', and 'A' (65) comes before 'a' (97):
စံကား
Expected output
မှန်
မှန်
Keeping the answer
A comparison is a value, so it can be stored in a boolean variable:
စံကား
Expected output
မှန်
One comparison at a time
Maths allows 1 < 2 < 3. Zaka does not allow a comparison inside another comparison:
စံကားZK0210
Expected error
error[ZK0210]: a comparison cannot be the operand of another comparison