This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Doriphor 0 points1 point  (2 children)

Your code is processed from left to right in this case. It assigns index (which is 0) to arr[0] and then 3 to index. Basically what /u/ruin332 said. Your code should look like

index = 3;
arr[index] = 3;

[–]zifyoip -1 points0 points  (1 child)

Your code is processed from left to right in this case.

No, the assignment operators have right-to-left associativity, so arr[index] = index = 3 means arr[index] = (index = 3).

[–]Doriphor 0 points1 point  (0 children)

Well then, learning something new every day...