A Multi-dimensional array implementation would be ...
# language-proposals
d
A Multi-dimensional array implementation would be cool, similar to the one in C#, rather than using Java's jagged arrays. So you could make a 2x4 array
arr
, and because we know the width and height are fixed to 2 and 4, we can make it a 1D array of length 8.
m
On JVM, arrays are references, so, unfortunately, this is valid (Java):
int[][] crap = { {1, 2}, {3, 4, 5}, null };
d
Sorry for the late reply. I understand how 2D arrays in Java work. But what I'm suggesting is a feature that, if specified in a 2D array (ex syntax:
Array2D<String>(2, 4)
which is stored internally as a single array of length 8, but from the outside is accessed as
arr2d[1, 3] //for last element
Is it okay to bump this thread? I feel like this would be extremely useful. Probably better for #stdlib though
m
You can write your own wrapper around arrays. This is not the case for #stdlib, but for a library.
­čĹŹ 2