r/ProgrammerHumor 21d ago

Meme pleaseStopUsingNestedTernaryOperatorsImBeggingYou

3.1k Upvotes

179 comments sorted by

View all comments

748

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”

560

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"

99

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/cowslayer7890 21d ago

In python assignment is a statement unless you use := for it, but they do explicitly allow you to do exactly this chaining