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,
Let's break that code:
getArray() [index=2]++;
is equivalent to:
int[] someArray = getArray(); // Assume that's an int[]
index = 2;
someArray[index]++;
The last line is equivalent to:
someArray[index] = someArray[index] + 1;
If you remove that ++
, then the 2nd expression is not a valid statement. It just becomes:
getArray() [index];
You have to assign that to some L-Value.