Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
5ytech
Visitor

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:{
"A"
"B"
"C"
"A"
"B"
"C"
"A"
"B"
}

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

Thanks,
Pradeep
0 Kudos
1 REPLY 1
RokuMarkn
Visitor

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
out.Push(item)
seen[item] = true
end for
return out
end function


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

--Mark
0 Kudos