Forum Discussion

EnTerr's avatar
EnTerr
Roku Guru
14 years ago

Why do CreateObject("roAssociativeArray")?

I am reading some sample code and i notice assoc.arrays commonly created as
aa = CreateObject("roAssociativeArray")
Why so complicated, why not do just
aa = { }
Seems much easier to type and i wonder if i am missing something, as to the reason why it was done (in what seems to me) more clumsy way.

Related to that, why do
aa.posterItems = CreateObject("roArray", 5, true)
and not
aa.PosterItems = [] 
, if for all practical purposes is the same?! (in both cases arrays are re-sizable; "5" is a just a hint about initial alloc, since arr.count()==0)

1 Reply

  • Per the docs, {} and [] are shortcuts for the CreateObjects. My guess is that they were added later in the lifecycle and the examples were never updated and/or it's still present to allow for explicit declaration for those who prefer it.