pmpascua
Visitor

How to specify a function to return as array?

Hello, New Roku guy here. 

I want to know how to specify a function to return an array. Not associated array, an Array. It seems obvious but defining it like this doesn't seem to work. 
function Foo() as Array 
return []
end function

I looked around but I haven't found an existing problem within the internet
Tags (1)
0 Kudos
6 REPLIES 6
squirreltown
Roku Guru

Re: How to specify a function to return as array?

I want to know how to specify a function to return an array. Not associated array, an Array. It seems obvious but defining it like this doesn't seem to work. 
function Foo() as Array 
return []
end function


bar = Foo()

function Foo() as Array 
bar = [0,1]
return bar
end function

Kinetics Screensavers
Tags (1)
0 Kudos
pmpascua
Visitor

Re: How to specify a function to return as array?

You basically wrote the same thing I did. The problem here is that the 'Array' part is treated as syntax array on eclipse.
Tags (1)
0 Kudos
pmpascua
Visitor

Re: How to specify a function to return as array?

Never mind, I found out through the syntax error that 'Array' is not a valid token
Tags (1)
0 Kudos
belltown
Roku Guru

Re: How to specify a function to return as array?

bar = Foo()

function Foo() as Object
bar = [0,1]
return bar
end function
Tags (1)
0 Kudos
Komag
Roku Guru

Re: How to specify a function to return as array?

As far as I know you can't specify an Array, only Object
You can have:
Integer
Float
String
Boolean
Object (a catchall for Roku objects such as Array, Associative Array, other?)
Tags (1)
0 Kudos
EnTerr
Roku Guru

Re: How to specify a function to return as array?

"Komag" wrote:
Object (a catchall for Roku objects such as Array, Associative Array, other?)

Yes. Object captures all things "ro-". [ ] and { } are roArray and roAssociativeArray, respectively.

You can see the full list of types at Expressions, Variables, and Types (Oh my!)
Tags (1)
0 Kudos
Community is Temporarily in Read-Only Mode!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!