Do you really need to if for non 0 length before foreach?
Seriously. For each knows the container is empty.
Dammit! lol you're right
Is preemptive code, supposing future changes, a bad practice?
What changes would that be? It's not very likely that forEach would change
Anything that doesn't have zero-length detection, before or after the loop.
So then you just add that when it's necessary, rather than having dead/redundant code.
In this case? Definitely. It needlessly introduces an additional if statement that increases complexity
No - to an extent. Yes - to this extent.
This is why I don’t trust Math.random() - it knows too much...
Wtf, having type as a string and not enum...
Could be like a string literal union in typescript, but still
Do you really need to if for non 0 length before foreach?
Seriously. For each knows the container is empty.
Dammit! lol you're right
Is preemptive code, supposing future changes, a bad practice?
What changes would that be? It's not very likely that forEach would change
Anything that doesn't have zero-length detection, before or after the loop.
So then you just add that when it's necessary, rather than having dead/redundant code.
In this case? Definitely. It needlessly introduces an additional if statement that increases complexity
No - to an extent. Yes - to this extent.