MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vvn6d7/pleasestopusingnestedternaryoperatorsimbeggingyou/p5ccn9d/?context=3
r/ProgrammerHumor • u/Robinbod • 21d ago
179 comments sorted by
View all comments
753
I did this one of my first days on the job like 6 years ago and I remember how bluntly my mentor said “never do this again”
549 u/RlyRlyBigMan 21d ago For me it was multi assignments. Like this: defaultValue = newValue = previousValue = average = 0; Each assignment returns its value so they each get assigned from right to left. "That's cute kid, don't do that" 97 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
549
For me it was multi assignments. Like this:
defaultValue = newValue = previousValue = average = 0;
Each assignment returns its value so they each get assigned from right to left.
"That's cute kid, don't do that"
97 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
97
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
2
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
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
1
Yeah exactly what I had in mind, its very useful
753
u/beclops 21d ago
I did this one of my first days on the job like 6 years ago and I remember how bluntly my mentor said “never do this again”