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

roArray/roAssociativeArray vs. []/{}

This is a rather basic question, since I just started playing with the SDK last night, so forgive me. (Background: I'm a C++/Java/PHP guy.)

I noticed there are roArray/roAssociativeArray objects, but also support built into the language in the form of [] and {} respectively. I replaced a 'roAssociativeArray' block from the example code with this...

	app = CreateObject("roAppManager")

theme = {
OverhangOffsetSD_X: "72",
OverhangOffsetSD_Y: "25",
OverhangSliceSD: "pkg:/images/Overhang_BackgroundSlice_Blue_SD43.png",
OverhangLogoSD: "pkg:/images/Logo_Overhang_Roku_SDK_SD43.png",

OverhangOffsetHD_X: "123",
OverhangOffsetHD_Y: "48",
OverhangSliceHD: "pkg:/images/Overhang_BackgroundSlice_Blue_HD.png",
OverhangLogoHD: "pkg:/images/Logo_Overhang_Roku_SDK_HD.png",

BackgroundColor: "#000000",
PosterScreenLine1Text: "#FFCC00",
ParagraphBodyrText: "#FFCC00",

SpringboardArtistLabel: "",
SpringboardArtistColor: "#000000",
}

app.SetTheme(theme)

...and it worked fine. Is there any non-obvious advantage to using the object form over the built-in? Or is it simply a matter of personal taste?
0 Kudos
2 REPLIES 2
jbrave
Channel Surfer

Re: roArray/roAssociativeArray vs. []/{}

I think the more serious object oriented programmers use this style, it allows some cool things I'm still wrapping my brain around, in spite of it being explained to me in three different ways by three different people.

see this post:
viewtopic.php?f=34&t=32557
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
RokuKevin
Visitor

Re: roArray/roAssociativeArray vs. []/{}

the squiggly brackets { } create an roAssociativeArray object just like the CreateObject("roAssociativeArray") does. You can create equivalent objects using either method.

The squiggly brackets offer a language shortcut to initializing the roAssociativeArray as they enable literal values to be assigned.

--Kevin
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.