Array union syntax: grumble or bug?

J. Landman Gay jacque at hyperactivesw.com
Sun Oct 7 13:13:21 EDT 2007


David Bovill wrote:
> This one has bothered me for a while now - is there a good reason for these
> two rather strange behaviors of the "union" command for arrays:
> 
>  1) union with an empty base array always result in empty instead of adding
> the new array
>  2) an array is "empty" even if it is not (null) and has stuff in it (same
> with other binary data)

I'm not sure what you mean by #2, but if the content isn't an array then 
the issue is probably the same as #1. I think the answer lies in the docs:

"The union command combines the array and testArray. Each key of the 
array is checked to see whether there is already an element with that 
key in the testArray."

Because each key in the base array is checked and compared, apparently 
if your base array is empty, nothing is checked. I'm guessing it would 
be similar to this:

repeat for each item i in myVar
   -- do stuff
end repeat

If myVar is empty, the repeat loop would not run. Ditto arrays 
(apparently) with the "union" command.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list