On Tuesday, 19 January 2016 at 05:32:07 UTC, Ali Çehreli wrote:

Ali, look what you said:

For example, the following is a row with two columns:

    int[2]

Then you said:

So, in order to get 1 row of 2 columns, you would write

    int[2][1]

So the first pair of square-brackets is the column and second is the row as you said above, but look what happens when I try to access thinking that way:

void main(){
        int[2][1] arr; // 2 columns & 1 row as Ali said...
        
        arr[0][0] = 1;
        arr[1][0] = 2;
}

ERROR:

/d609/f167.d(14): Error: array index 1 is out of bounds arr[0 .. 1] /d609/f167.d(14): Error: array index 1 is out of bounds arr[0 .. 1]


So now the first pair of brackets in fact is the ROW and the second is the COLUMN, because this works:

void main(){
        int[2][1] arr; // 2 columns & 1 row
        
        arr[0][0] = 1;
        arr[0][1] = 2;
}

Maybe I'm really dumb, but you need to agree that even with your good explanation it still doesn't making sense.

Albert.

Reply via email to