Weird array comparison limitation
Alex Tweedly
alex at tweedly.net
Wed Nov 28 15:43:24 EST 2012
You can compare two arrays for being equal - but you can't compare them
for being unequal !
As the dictionary says (under the "=" operator), you can compare two
arrays, and it will check that the number of keys is the same, and then
that each element is the same - therefore it works just like you'd hope
and expect for multi-level arrays.
But the dictionary entry for "is not" (i.e. not equal, the "<>"
operator) does not mention arrays, and indeed you cannot get reliable
results from it (ok- they *may* be reliable - but they're not useful :-)
Here's a snippet from my Message Box - the global array gives me data to
start with, I copy it, then change it, so they are in fact not quite the
same - one element has been changed ....
> global gATermInfo
> put gAtermInfo into gA2
> add 1 to gA2["year"]
> put gA2["year"] && (gATerminfo = gA2 ) && (gATerminfo <> gA2 )
>
produces
> 2013 false false
I guess it's not strictly speaking a bug, since the dictionary doesn't
claim that it should do the sensible thing. But it's so intuitively
obvious that it ought to work, and must be so easy to make it work, that
I kind of think it should be fixed.
Or am I missing some reason ? or some history that would demand
backwards compatability ?
Thanks
-- Alex.
More information about the use-livecode
mailing list