2 ms·
There's a lot of cases where you can't "just use a for loop" such as if you're looping over something else, or if you're looping over 2 things. For example repl
by kllrnohj 8y ago
There's a lot of cases where you can't "just use a for loop" such as if you're looping over something else, or if you're looping over 2 things. For example replace it with something like:
data[i++] += other[j++]
Yeah you could do this other ways, but it's not actually uncommon. You'll see this sort of thing in collection implementations regularly, for example, or things doing parsing. Not necessarily with the append operator as well, but certainly indexing into an array with a ++ variable.