[full text of the original email appears below] Start with "Rev only uses associative arrays" thus you need to get the key list for access. There is a feature request to add "indexed" access, which would allow dataArr[0] dataArr[1] etc
Second "Rev allows variables without 'variable typing' or 'casting' thus accessing a 'base array' is accessing an empty key list, which would mean the variable "dataArr" is not really an array yet. This also allows the operation: put "sunny day" into dataArr["weather"] put "78 degrees" into dataArr["temperature"] put keys(dataArr) into msg put "any old string" into dataArr --datArr is no longer an array put keys(dataArr) into msg --> empty Third "Rev finds an empty key list, and does not do a comparison to add keys from the new array ( since an empty array is not technically an array yet, just a variable )" thus put newArr into dataArr --would be the operation, as you have shown This is one of the ways "non-type-casting variable" handling means different programming conventions. To answer your two questions: > 1) union with an empty base array always result in empty instead of adding > the new array because the 'keys of this variable' are empty > 2) an array is "empty" even if it is not (null) and has stuff in it (same > with other binary data) because the 'keys of this variable' are NOT empty, and you need to use the list of keys to access the data. Hope this helps Jim Ault Las Vegas On 10/7/07 5:07 AM, "David Bovill" <[EMAIL PROTECTED]> 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) > > So AFAIK to add an array in a repeat loop to an initially empty array you > need to use an awkward and slow handler like the one below: > > on array_Add someArray, @toArray > -- why cant we just test if array is empty? > if keys(toArray) is empty then > -- why does "union" with an empty base array always result in empty? > put someArray into toArray > else > union toArray with someArray > end if > end array_Add _______________________________________________ use-revolution mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
