Using Operators in Condition Expressions

The following are the boolean operators that can be used within the boolean expression specifying the condition:

Type

Description

Type

Description

Boolean and or &

The operator && can be used as well as the word and to specify composing conditions, e.g. cond1 and cond2 and cond1 && cond2

Boolean or or ||

The operator || can be used as well as the word or to specify composing conditions, e.g. cond1 or cond2 and cond1 || cond2

Boolean not or !

The operator ! can be used as well as the word not to specify composing conditions, e.g. !cond and not cond

Boolean &

The bitwise operator & is used as follows !cond and not cond

Ternary conditional ?:

The ternary conditional operator condition ? if_true : if_false operator can be used as well as the abbreviation value ?: if_false which returns the value if its evaluation is defined, non-null and non-false.The condition will evaluate to false when it refers to an undefined variable or null. e.g. val1 ? val1 : val2 and val1 ?: val2 , Where val1 and val2 could be true or false.

Equality == or eq

The usual == operator can be used as well as the abbreviation eq. For example val1 == val2 and val1 eq val2 null is only ever equal to null, that is if you compare null to any non-null value, the result is false.

InEquality != or ne

The usual != operator can be used as well as the abbreviation ne. For exampleval1 != val2 and val1 ne val2

Less Than < or lt

The usual < operator can be used as well as the abbreviation lt. For example val1 < val2 and val1 lt val2

Less Than or Equal To <= or le

The usual <= operator can be used as well as the abbreviation lt. For example val1 <= val2 and val1 le val2

Greater Than > or gt

The usual > operator can be used as well as the abbreviation gt. For example val1 > val2 and val1 gt val2

Greater Than or Equal To >= or ge

The usual >= operator can be used as well as the abbreviation gt. For example val1 >= val2 and val1 ge val2

In or Match =~

=~ operator can be used to check that a string matches a regular expression. For example "abcdef" =~ "abc.* returns true. It also checks whether any collection, set or map (on keys) contains a value or not; in that case, it behaves as an "in" operator. Note that arrays and user classes exposing a public 'contains' method will allow their instances to behave as right-hand side operands of this operator. "a" =~ ["a","b","c","d","e",f"] returns true

Not-In or Not-Match !~

!~ operator can be used to check that a string does not match a regular expression. For example "abcdef" !~ "abc.* returns false. It also checks whether any collection, set or map (on keys) does not contain a value; in that case, it behaves as "not in" operator. Note that arrays and user classes exposing a public 'contains' method will allow their instances to behave as right-hand side operands of this operator. "a" !~ ["a","b","c","d","e",f"] returns true

Starts With =^

The =^ operator is a short-hand for the 'startsWith' method. For example, "abcdef" =^ "abc" returns true

Not Starts With !^

This is the negation of the 'starts with' operator. a !^ "abc" is equivalent to !(a =^ "abc")

Ends With =$

The =$ operator is a short-hand for the 'endsWith' method. For example, "abcdef" =$ "def" returns true

Not Ends With !$

This is the negation of the 'ends with' operator. a !$ "abc" is equivalent to !(a =$ "abc")

If/Then

Traditional if ... then could be used, but they have to return either true or false, e.g. `if ((runtime['x'] * 2) == token['DQ']['output']) { false; } else { true; }

 

Created in 2020 by Google Inc.