Logical Expressions
Comparison Operators
Operators relating to comparison are:
==
: Strict equality comparison operator!=
: Strict inequality comparison operator>
: "Greater Than" comparison operator<
: "Less Than" comparison operator>=
: "Greater Than or Equal To" comparison operator<=
: "Less Than or Equal To" comparison operator
In JavaScript, equality comparison have two versions: ==
and ===
which the latter one is strict version of the equality comparison.
Hence, when using ==
in Wyrd, it will compiled into strict version of the code:
The returned result of logical operation will always return data of type Bool
.
Comparison Operators Accept Identical Types Only
When comparing two different type of data, Wyrd will throw error message:
TODO: This behavior may be override by using "operator overloading", currently this feature hasn't implemented yet
Logical Chaining
Sometimes we would want more than one comparisons chained together using AND/OR or NOT relationships. Thus, Wyrd provides three keywords and
, or
and not
to chain logical expressions. And of course, these keywords will be compiled in JavaScript which maps to &&
, ||
and !
operators.
And of course, you can chain not only Bool
type values, you can chain multiple comparison operations:
TODO: Handle Logical Expressions Where AND/OR and NOT Operation Should Only Accept Boolean Values
Last updated
Was this helpful?