2 ms·
index++ uses the variable and then increments it. From top of head, no doubt and 100% sure. ++index would do the opposite order. It is easy to remember and make
by watwut 8y ago
index++ uses the variable and then increments it. From top of head, no doubt and 100% sure. ++index would do the opposite order. It is easy to remember and makes sense.
The ++ operator is not obscure at all and used more often then for example += operator.
- chrisseaton 8y agoI've said 'in general' several times. I shy away from inline side effects because in general I do not intuitively understand how they sequence. I'd rather just avoid in general.
- Retra 8y agoThat's your prerogative then, isn't it?
- chrisseaton 8y agoWhat does the JVM language specification say about this? That's a pretty universal opinion we can all agree to follow. 15.7, Evaluation Order: > It is recommended that code not rely crucially on this specification. Code is usually clearer when each expression contains at most one side effect, as its outermost operation, and when code does not depend on exactly which exception arises as a consequence of the left-to-right evaluation of expressions. So when I review I advise, as per the spec, that expressions contain a single side effect.
- deleted 8y ago[deleted]