Re: [Vala] how to access the length attribute of multi dimensional arrays?





On 02/07/10 00:26, Seth Hoenig wrote:
So if I pass a matrix to a function (or any multidimensional array), I can
only seem to access the .length attribute of the first dimension. Is there a
way to access the .length attributes of the other dimensions of the array?

public Something(int[,] arr)
{
_n_rows =  arr.length;
_n_cols =   arr[0, ].length; // no compile :(
}

In the example above, I can't seem to find a way to find out how many
columns are in my matrix.


If I recall correctly, multidimensional arrays have an arrayed length member - i.e.

public Something(int[,] arr)
{
  _n_rows =  arr.length[0];
  _n_cols =   arr.length[1];
}

HTH,
Rob





_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list

--

Rob Taylor, Managing Director, Codethink Ltd. - http://codethink.co.uk
Twitter: #robtaylor78 - LinkedIn: http://www.linkedin.com/in/robtaylor78



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]