3 ms·
> not modify the object that you are looping over from within the loop That isn't happening. The loop is over an integral range (1..5 in both examples). That
by Supermancho 7y ago
> not modify the object that you are looping over from within the loop
That isn't happening. The loop is over an integral range (1..5 in both examples). That integer is being hashed in the example and the hash is being used for a SIDE EFFECT. Internally, the select() is doing the exact same thing, but there is no label on the value and it's being returned out of the ostensible container function.
This is not a good example of why this pattern is bad nor of why side effects are bad.