Returning an array from a method?

Is there some reason why the IDE doesn’t allow a method to return an array of some type (or an array of objects of some class) ? Yet it is easy to do this, by defining the method as returning a variant, eg:

Public Function MakeAnArray() As Variant
var a() as integer

a.add 1
a.add 2
a.add 3
a.add 4
return a
End Function

Creating a button with the following in the “Pressed” event handler it works as expected, viz:

Var anArray() as integer
Var result as string

anArray = MakeAnArray()

for each i as integer in anArray
result = result + str(i) +" "

MessageBox result

Function AnArray () As Integer()

Ah thanks Kem… must be having a blonde moment, d’oh.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.