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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

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",


...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
Level 8

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:
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
Level 9

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.

0 Kudos