[Gambas-user] Dynamic multi-dimensional array?

Tobias Boege taboege at ...626...
Mon Jun 23 18:33:19 CEST 2014


On Mon, 23 Jun 2014, Rezedent12 . wrote:
> Is it possible to dynamic multi-dimensional arrays?
> 
> Static multi-dimensional array may declare Ps As New Integer [10,100]
> 
> Dynamic dimensional possibly Ps As New Integer []
> 
> How to declare a dynamic multidimensional array? I tried Ps As New Integer
> [,] but it is not syntactically correct. I decided to temporarily apply Ps
> As New Integer [] []. Create a dynamic array of dynamic arrays. But this is
> not what I need [x] [y], I need to [x, y]. Is it possible?
> 
> 

The preferred way[*] of having dynamic multidimensional arrays is actually
the Integer[][]...[] syntax, one pair of "[]" for each dimension.

If you for some reason cannot possibly bear the [x][y] syntax, you may also
create a distinct class which implements the _get() and _put() special
methods and wrap the arguments for a call to a typical Gambas md-array.

There's actually to be some thought involved in the latter procedure if you
want to handle arbitrary dimensions and I don't know off the top of my head
if it's at all possible. But if you need it, maybe we can do something...

[*] It's preferred for various reasons. If you want to hear some, just ask.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list