ProgrammerHumor

helloNeo

helloNeo
https://i.redd.it/jr89reom2icf1.png
Reddit

Discussion

Haris613

Do you really need to if for non 0 length before foreach?

22 hours ago
erkose

Seriously. For each knows the container is empty.

22 hours ago
Duroktar OP

Dammit! lol you're right

21 hours ago
LuciusWrath
:cs:

Is preemptive code, supposing future changes, a bad practice?

15 hours ago
Sikletrynet

What changes would that be? It's not very likely that forEach would change

10 hours ago
LuciusWrath
:cs:

Anything that doesn't have zero-length detection, before or after the loop.

6 hours ago
Sikletrynet

So then you just add that when it's necessary, rather than having dead/redundant code.

4 hours ago
shortfinal

More correctly: you add that when your unit test detects an underlying behavioral change that blocks your build pipeline.

2 hours ago
Top-Permit6835

In this case? Definitely. It needlessly introduces an additional if statement that increases complexity

10 hours ago
rtybanana
:cs::ts::dart::asm:

No - to an extent. Yes - to this extent.

7 hours ago
driedcranberryman

This is why I don’t trust Math.random() - it knows too much...

22 hours ago
Neverwish_
:cs:

Wtf, having type as a string and not enum...

20 hours ago
mampatrick

Could be like a string literal union in typescript, but still

18 hours ago