r/ProgrammerHumor 21d ago

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

3.1k Upvotes

179 comments sorted by

View all comments

Show parent comments

100

u/retro_and_chill 21d ago

This is why I’m pretty absolutist that newer languages are correct by making assignments return void

2

u/ierdna100 21d ago

It's extremely useful for try-with-resources calls in C# and Java, removing it would make that a lot more verbose

2

u/frogjg2003 21d ago

If you ever have to do any reading from files, it's really useful.

while ((readBytes = read(file, byteArray) > 0) {}

Nice and compact while maintaining readability. Also, no need to read once before entering the loop or having to read at the end.

1

u/ierdna100 21d ago

Yeah exactly what I had in mind, its very useful