Comparison Operations
An expression in HCL
Detect Expression Language can contain the basic comparison
operations: greater than (>), greater than or equal
(>=), less than (<), less than or equal
(<=), equals (==), and not equals
(!=) with the usual semantics. These are binary operations.
With the exception of equals and not equals, they expect sub-expressions of
numerical types or strings on each side. For strings, the comparison is based on
lexicographic order. For equals and not equals, the left and the right
sub-expressions must be of compatible types with respect to HCL
Detect Expression
Language coercion rules. The result of the comparison is always of type
Bool.
Examples:
- An expression using comparisons:
3>5 - An expression using String comparisons:
"abc"<"def" - An expression using inequality comparison:
"abc"!="def" - An expression comparing a
Doubleliteral with aNaN(not a number) value:10.5 != Double("nan")(Note that in this case, themath.isNaNbuilt-in function can also be used.) - An expression comparing a
Doubleliteral with anInf(positive infinity) value:10.5 != Double("inf")(Note that in this case, themath.isPositiveInfinitybuilt-in function can also be used.) - An expression comparing a
Doubleliteral with a-Inf(negative infinity) value:10.5 != Double("-inf")(Note that in this case, themath.isNegativeInfinitybuilt-in function can also be used.)