Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Komag
Level 9

roAssociativeArray Appen() doesn't append nested roAssociativeArrays!

I've discovered, to my dismay, that when you append one AA (roAssociativeArray) to another one, if it finds any same keys it will REPLACE it! Yes, I know that's exactly what it says it will do, so good for it for being literal, but I just figured if it found a nested AA it would nicely Append() it, rather than replace it.

This is what I want, or maybe a different but similar command, such as NestAppend() or something.

As it is, I have to manually deal with this, and for now, thankfully only one layer, so I can go through each key/value in the top AA and Append() each of those one at a time, with a big FOR EACH loop.
0 Kudos
2 Replies
Roku Employee
Roku Employee

Re: roAssociativeArray Appen() doesn't append nested roAssociativeArrays!

The name ".append()" is an unfortunate misnomer. Method should have been named ".update()", because that's what it does: A.append(B) adds (if new) to A - or replaces (if pre-existing) - key-value pairs from B. It is a shorter (and faster) version of:
for each key in B 
A[key] = B[key]
next
0 Kudos
Komag
Level 9

Re: roAssociativeArray Appen() doesn't append nested roAssociativeArrays!

Yeah, that makes it more clear.
0 Kudos