Relational expressions

Gosu relational operators support all types of objects that implements the java.lang.Comparable interface, not just numbers. Relational expressions return a Boolean value (true or false) indicating the result of a comparison between two expressions. Relational expressions use the following operators:

  • > operator
  • >= operator
  • < operator
  • <= operator

Gosu supports the use of multiple relatational operators to compare multiple values. Add parentheses around each comparison expression. For example, the following expression ultimately evaluates to true:

((1 <= 2) <= (3 > 4)) >= (5 > 6)

The first compound expression evaluates to false ((1 <= 2) <= (3 > 4)) as does the second expression (5 > 6). However, the larger expression tests for greater than or equal. Therefore, because false is equal to false, the entire expression evaluates to true.

> operator

The > operator tests two expressions and returns true if the left value is greater than the right value. The operands can be numeric, String, or java.util.Date data types. The result is Boolean.

Syntax

expression1 > expression2

Examples

Expression

Result

8 > 8

false

"zoo" > "apple"

true

5 > "6"

false

currentDate > policyEffectiveDate

true

>= operator

The >= operator tests two expressions and returns true if the left value is greater than or equal to the right value. The operands can be numeric, String, or java.util.Date data types. The result is Boolean.

Syntax

expression1 >= expression2

Examples

Expression

Result

8 >= 8

true

"zoo" >= "zoo"

true

5 >= "6"

false

currentDate >= policyEffectiveDate

true

< operator

The < operator tests two expressions and returns true if the left value is less than the right value. The operands can be numeric, String, or java.util.Date data types. The result is Boolean.

Syntax

expression1 < expression2

Examples

Expression

Result

8 < 5

false

"zoo" < "zoo"

false

5 < "6"

true

currentDate < policyEffectiveDate

false

<= operator

The <= operator tests two expressions and returns true if the left value is less than or equal to the right value. The operands can be numeric, String, or java.util.Date data types. The result is Boolean.

Syntax

expression1 <= expression2

Examples

Expression

Result

8 <= 5

false

"zoo" <= "zoo"

true

5 <= "6"

true

currentDate <= policyEffectiveDate

false