Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is that more of a jagged / ragged array, or array of arrays? Sometimes these are called multidimensional arrays, but these are not the same thing. Dimensions and lengths of the dimensions should be a property of the multidimensional object.

[1] https://stackoverflow.com/questions/597720/what-are-the-diff...



I was talking about

  int a[2][3];
in C. Is that jagged? I wouldn’t have thought so, since AFAIK you could only store 6 elements in that and no fewer. Interestingly you cannot take the value of &&a[0][0], assign it to an

  int **b;
pointer b, and then access it via b[0][0] because it’s stored as a contiguous block of integers rather than an array of pointers that point to arrays as you might expect.


Yes, that's a jagged/ragged/array-of-array, and most languages support them. There isn't a requirement for the arrays to be the same length. There are many arguments about the pros and cons of each, and how different they are the closer to assembly you get. Golang had a proposition to include multidimensional arrays [1], there were lots of arguments. I think the different perspectives depend on what you want to use it for and how much numerical processing you do.

[1] https://github.com/golang/go/issues/6282


According to this thread, it is not a true jagged array because each row has the same number of columns and each column the same number of rows. You can initialize it as a jagged array but it will still allocate it like a matrix.

https://stackoverflow.com/questions/1083658/do-jagged-arrays...

> the array will still have the shape [2][3]. If you want a true jagged array, you will have to create it dynamically.


Ah ok, I was discriminating between a true multidimensional array and array-of-array (which can be ragged).




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: