B4J Question Initializing multiple array

marcopoilo

Member
Licensed User
Is it possible to initialize a multi-dimension array as for one dimension.
For example as (which does not work):

Dim y(2,3) As Double
y = Array As Double((1,2),(3,4),(5,6))
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is no special syntax for multi-dimension arrays. However you can for example create a list of points:
B4X:
Dim Points As List = Array(Array As Double(1, 2), Array As Double(3, 4), Array As Double(5, 6))
For Each point() As Double In Points
    Log(point(0) & " x " & point(1))
Next
Or better, declare your own custom type, hover over the type, choose "generate Create Type sub' and use it to create a list of custom types.
 
Upvote 0
Top