Multidimensional arrays in Boo
When declaring a variable or a field as a multidimensional array, use this syntax:
When creating a brand spanking new multidimensional array, use this syntax:
foo = matrix(int, 2, 3, 4)
Set and retrieve data from the array:
foo[0,0,1] = 100
print foo[0,0,1]
This shows looping over the array to set or get values:
n = 1
for i in range(len(foo,0)): for j in range(len(foo,1)): for k in range(len(foo,2)): foo[i,j,k] = n
++n
columns = len(foo, foo.Rank - 1)
line = []
for item in foo:
line.Add(item.ToString("00"))
if len(line) >= columns:
print join(line)
line.Clear()
The whole code together produces this output:
See also Lists And Arrays. Slicing works for multidimensional arrays too.