Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

remove repeating objects in the array

Hello, I want to remove the repeating objects in roArray. How can we do that?
ex if i have a array:{

my output array should be like:
A, B, C

0 Kudos
1 REPLY 1\
Level 8

Re: remove repeating objects in the array

There's no built-in way to do that, but you can write a simple loop and keep track of what items you've seen with an associative array. Something like this:

function RemoveDups(array as Object) as Object
out = []
seen = {}
for each item in array
if seen[item] = invalid then
seen[item] = true
end for
return out
end function

I haven't tested this, it might require some tweaking.

0 Kudos