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: 
bernie_zhao
Visitor

object comparison

Hi I'm a newbie to Roku.
A very basic question, how do you compare two objects.
Obviously I didn't expect the following not work

a={ a1:"ok" }
b={ b1:"ok2" }
c = a
if a=c then ' this line generates "Type Mismatch"
endif

In debug console, I tried ?a=b or ?a<>b, both generate same type mismatch error.

In Roku SDK it says objects are assigned by reference, which leads me to naturally believe object comparison is same as other languages such as java, javascript, c#...etc.

Any help is appreciated!
0 Kudos
3 REPLIES 3
bernie_zhao
Visitor

Re: object comparison

A little more context...

I'm storing a bunch of objects (AA) in an array.
And upon removal I need to find the object and delete it from array.
I'm looping the array to "find it". But in order to find it I need to compare the one I'm searching for with the one in the array.
Hence the question.
0 Kudos
RokuMarkn
Visitor

Re: object comparison

I don't think Brightscript supports comparisons between AAs. You could add an integer ID value to each of your AAs and compare that.

--Mark
0 Kudos
bernie_zhao
Visitor

Re: object comparison

Thanks Mark!
So I assume the limitation is not only on AA, but also on all objects that you created by CreateObject?

This sounds a little tricky if you want to maintain your own stack of screen objects.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.