Was this page helpful?

Relational Operators

    == Operator

    Used to test if two values are equal.  If needed, the == operator will automatically convert the type of a value to perform the comparison.

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 == "123" }} 

    true

    To compare a numeric expression with a concatenated string:

    {{ (10 + 3) == "1" ..  "3" }}

    true

     

    != Operator

    Used to test if two values are not equal.  If needed, the != operator will automatically convert the type of a value to perform the comparison.

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 != "123" }} 

    false

    To compare a numeric expression with a concatenated string:

    {{ (10 + 3) != "1" ..  "3" }}

    false


    === Operator

    Used to test if two values are equal.  The === operator only succeeds if the two values have the same type and are equal. 

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 === "123" }} 

    false

    To compare a numeric expression with a value:

    {{ (10 + 3) === 13 }}

    true


    !== Operator

    Used to test if two values are not equal.  The !== operator only fails if the two values have the same type and are equal.

     

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 !== "123" }} 

    true

    To compare a numeric expression with a value:

    {{ (10 + 3) !== 13 }}

    false


    < Operator

    Returns returns true if the first operand is less than the second, false otherwise.  Both operands must be convertible to the same type, which must be one of bool, num, or str. If the operands cannot be converted to one of these types, the operator will evaluate to nil.  Otherwise, they are compared as follows: for values of type bool or num the values are compares numerically; for values of type str the characters of the string are compared first to last according to the current locale.  

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 < "123" }}

    false

     

    To compare two strings:

    {{ "abc" < "def" }}

    true


    <= Operator

    Returns returns true if the first operand is less than or equal to the second, false otherwise.  Both operands must be convertible to the same type, which must be one of bool, num, or str. If the operands cannot be converted to one of these types, the operator will evaluate to nil.  Otherwise, they are compared as follows: for values of type bool or num the values are compares numerically; for values of type str the characters of the string are compared first to last according to the current locale.  

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 <= "123" }}

    true

     

    To compare two strings:

    {{ "abc" <= "def" }}

    true


    >= Operator

    Returns returns true if the first operand is greater than or equal to the second, false otherwise.  Both operands must be convertible to the same type, which must be one of bool, num, or str. If the operands cannot be converted to one of these types, the operator will evaluate to nil.  Otherwise, they are compared as follows: for values of type bool or num the values are compares numerically; for values of type str the characters of the string are compared first to last according to the current locale.  

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 >= "123" }}

    true

     

    To compare two strings:

    {{ "abc" >= "def" }}

    false


    > Operator

    Returns returns true if the first operand is greater than the second, false otherwise.  Both operands must be convertible to the same type, which must be one of bool, num, or str. If the operands cannot be converted to one of these types, the operator will evaluate to nil.  Otherwise, they are compared as follows: for values of type bool or num the values are compares numerically; for values of type str the characters of the string are compared first to last according to the current locale.  

    Usage Restrictions

    1.8.3 or later.

    Samples


    Output

    To compare a number with its string equivalent:

    {{ 123 > "123" }}

    false

     

    To compare two strings:

    {{ "abc" > "def" }}

    false

    is Operator

    is Operator 

    Was this page helpful?
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by