2 ms·
for(int i : some-container) { do-something-with(i); } Where is the mutation?
by gpderetta 1y ago
for(int i : some-container) {
do-something-with(i);
}
Where is the mutation?
- mrkeen 1y agoIt's implied by void-returning do-something-with(...). Otherwise you're just burning cycles and a good compiler should dead-code eliminate the whole loop. (see https://news.ycombinator.com/item?id=44873488 https://news.ycombinator.com/item?id=44873488)
- gpderetta 1y agoWe are discussing mutation in the loop itself, but sure: for(int x: container) { yield frob(x); }