Data types and Operators

Operator == Foundation

Exactly equal operator (binary): tests whether two values are identical.

Syntax
<Expression1> == <Expression2>
Parameters
<Expression>
<Expression1> and <Expression2> are expressions of the same data type or the value NIL. The exactly equal operator tests whether the values of the two expressions are identical. Each data type can be tested on exactly equal NIL.
Description

The exactly equal operator compares two values of the same data type and returns the result of the comparison as a logical value. The result is .T. (true) only when the value of <Expression1> is identical with the value of <Expression2>. Otherwise it is .F. (false).

Comparison with NIL

The operator can compare values of all data types (including array, code block and object) with the value NIL. In this case the value .T. (true) is returned only when both expressions are equal to NIL.

Comparison of characters

The exactly equal operator does not consider the settings of SET EXACT ON | OFF and SET LEXICAL ON | OFF. It compares characters only on the basis of their ASCII code. Each ASCII code is a numeric value which represents a character ("A" is 65 and "Z" is 90, meaning. "A" is smaller than "Z"). The operator returns the value .T. (true) only when both character strings contain exactly the same characters.

Comparison of date values

Values with data type date are compared with each other on a chronological basis.

Comparison of logical values

The value .F. (false) is not equal to the value .T. (true).

Comparison of numeric values

The comparison is based on the sizes of the numeric values.

Comparison of arrays, code blocks and objectsA variable containing an array, code block or object contains only a reference to its contents (its value). With these data types, the comparison is based on the references, not the values,. The exact equal operator returns the value .T. (true) only when two variables contain the same reference. In this case, the values of both variables are also identical.

Examples
The exactly equal operator (==)
// This example illustrates the results of the exactly 
// equal operator with various comparison expressions. 

PROCEDURE Main 
   LOCAL var1, var2, var3 
                                    // variables are NIL 
   ? var1 == var2                   // result: .T. 
   ? var1 == NIL                    // result: .T. 

                                    // character value 
   ? "A"  == "A"                    // result: .T. 
   ? "A"  == "A "                   // result: .F. 
   ? "A " == "A"                    // result: .F. 
   ? ""   == "A"                    // result: .F. 
   ? "A"  == ""                     // result: .F. 
   ? "AB" == "ABC"                  // result: .F. 
   ? "ABC"== "AB"                   // result: .F. 
   ? "ABC"== "ABC"                  // result: .T. 

                                    // Code block 
   var1 := {|x| x+4 }               // assign the code block reference 
   var2 := {|x| x+4 }               // new code block reference 
   var3 := var1 

   ? var1 == var2                   // result: .F. 
   ? var1 == var3                   // result: .T. 

                                    // Array 
   var1 := { 1,.T., "Xbase++" }     // assign the array reference 
   var2 := { 1,.T., "Xbase++" }     // new array reference 
   var3 := var1 

   ? var1 == var2                   // result: .F. 
   ? var1 == var3                   // result: .T. 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.