Version

    Relational Operators

    The following operators serve to compare some subexpressions when you want to obtain a boolean value result. Each of the mentioned signs can be used. These signs can be used more times in one expression. In such a case you can express priority of comparisons by parentheses.

    If you choose the .operator. syntax, operator must be surrounded by white spaces. Example syntax for the eq operator:

    Code Working?

    5 .eq. 3

    5 == 3

    5 eq 3

    5.eq(3)

    • Greater than

      Each of the two signs below can be used to compare expressions consisting of numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data types.

      • >
      • .gt.
      boolean a = 4 > 3;
      a = "dog" > "cat";
      if ( date1 > date2 ) {}
    • Greater than or equal to

      Each of the three signs below can be used to compare expressions consisting of the numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data types.

      • >=
      • =>
      • .ge.
      boolean a = 3.5 >= 3.5;
      a = "ls" >= "lsof";
      a = date1 >= date2;
    • Less than

      Each of the two signs below can be used to compare expressions consisting of numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data types.

      • <
      • .lt.
    • Less than or equal to

      Each of the three signs below can be used to compare expressions consisting of the numeric, date and string data types. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data types.

      • <=
      • =<
      • .le.
      int a = 7L < 8L;
      if ( "awk" < "java" ) {}
      a = date1 < date2;
    • Equal to

      Each of the two signs below can be used to compare expressions of any data type. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data types.

      • ==
      • .eq.
      if( 5 == 5 ) {}
    • Not equal to

      Each of the three signs below can be used to compare expressions of any data type. Both data types in the expressions must be comparable. The result can depend on the order of the two expressions if they are of different data types.

      • !=
      • <>
      • .ne.
      if ( 9 != 8 ) {}
    • Matches regular expression

      The operator serves to compare string and some regular expression. It returns true, if the whole string matches the regular expression, otherwise returns false. If the right operand is null, operator fails.

      boolean b = "cat" ~= "[a-z]{3}";
      • ~=
      • .regex.
      boolean b1 = "new bookcase" ~= ".*book.*";  // true
      boolean b2 = "new bookcase" ~= "book";      // false
      boolean b3 = "new bookcase" ~= null;        // fails
    • Contains regular expression

      The operator serves to compare string and some regular expression. It returns true, if the string contains a substring that matches the regular expression, otherwise returns false.

      • ?=
      boolean b = "miredo" ?= "redo";
    "typeof" Operator

    boolean <value> typeof <type or metadata name>

    Tests if a value (left operand) is of the specified type (right operand).

    Returns false if the value is null.

    For lists and maps, does not check the type of elements.

    Example 80. Usage of typeof
    variant myVariant = 5;
    if (myVariant typeof integer) { } // TRUE
    if (myVariant typeof number) { } // FALSE
    if (myVariant typeof string) { } // FALSE
    
    variant someObject = {"a" -> 1, true -> false};
    if (someObject typeof map) { // TRUE
         // handle map
    } else if (someObject typeof list) { // FALSE
         // handle list
    }
    
    variant nullVariant = null;
    if (nullVariant typeof string) { } // null returns FALSE for all types
    
    myMetadata myRecord;
    variant recordVariant = myRecord;
    if (recordVariant typeof record) { } // TRUE - generic record
    if (recordVariant typeof myMetadata) { } // TRUE - specific metadata
    if (recordVariant typeof otherMetadata) { } // FALSE - specific metadata

    See also: variant, cast, getType