Nested array comparisons

Dick Kriesel dick.kriesel at mail.com
Sat Mar 23 16:45:18 EDT 2013


On Mar 23, 2013, at 12:43 PM, David Beck <david at rotundasoftware.com> wrote:

> 
> If one has two nested arrays, can you compare the two for equality by doing
> 
> if deepArray_1 is deepArray_2 then
>   -- do whatever
> end if
> 
> It looks like this does not work. That is, you get false positives at times when the two arrays are in fact not equal. Can not find documentation to determine whether this is bug of the expected behavior!
> 
> David Beck

Hi, David.  Does it work if you use "=" instead of "is"?

See the dictionary entry for "=".  It says, in part:

"When comparing arrays, the = operator first checks if the number of elements in each array is the same, if not the two arrays are different. If the arrays have the same number of elements, they are equal if each element is equal. Specifically this means:

array1 = array2 if (and only if):
  - the number of elements of array1 = the number of elements of array2 and
  - for each element e in array1, array1[e] = array2[e]."

-- Dick



More information about the use-livecode mailing list