3 ms·
Why don't you simply replace index++, value=list->items[index] with value=list->items[++index] ?
by vog 16y ago
Why don't you simply replace
index++, value=list->items[index]
with
value=list->items[++index]
?
- alexgartrell 16y agoI did initially, until I looked up [1] and changed it in the edit. I figure separating it is cleaner. [1] http://en.wikipedia.org/wiki/Comma_operator http://en.wikipedia.org/wiki/Comma_operator
- vog 16y agoBut the combined expression solves exactly your problem! You were not sure whether the increment would always happen before the assignment. In the combined expression you can simply use the pre-increment operator, which will always increment before the rest of the expression. It's shorter, unambiguous and leaves less questions. How can something be any "cleaner" than that? Also, the statements "array[index++]" and "array[++index]" are pretty well-understood idioms in C.