Need help understanding strange array syntax

后端 未结 3 1145
深忆病人
深忆病人 2021-01-29 02:42

I found this bit in a book and I don\'t get what it does:

int index = 1;
...
getArray() [index=2]++;

[index=2]++; looks strange to me,

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-29 03:15

    getArray() must return an array of numbers (let's say ints), so getArray() [index=2]++; dissected:

    int index = 2;
    int[] array = getArray();
    array[index] = array[index] + 1;
    

提交回复
热议问题