MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1sgk92i/a_very_readable_ternary/
r/programminghorror • u/MarkAllSevens • Apr 09 '26
12 comments sorted by
29
This isn’t that bad at all
17
I mean....is pretty readable? Depending on what "ShouldFlipH" is doing this isn't that bad.
14 u/[deleted] Apr 09 '26 edited Apr 09 '26 [removed] — view removed comment 2 u/iain_1986 Apr 09 '26 Sure, but this instance being inverse for me doesn't make it particularly hard to read :shrug: 1 u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Apr 09 '26 The other one might be slightly easier to understand, but maybe yours is less bug prone since you only need ScorePanel and ScorePanelInverted once.
14
[removed] — view removed comment
2 u/iain_1986 Apr 09 '26 Sure, but this instance being inverse for me doesn't make it particularly hard to read :shrug: 1 u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Apr 09 '26 The other one might be slightly easier to understand, but maybe yours is less bug prone since you only need ScorePanel and ScorePanelInverted once.
2
Sure, but this instance being inverse for me doesn't make it particularly hard to read :shrug:
1
The other one might be slightly easier to understand, but maybe yours is less bug prone since you only need ScorePanel and ScorePanelInverted once.
ScorePanel
ScorePanelInverted
6
You could combine the nested turnaries with "flipH() == forTeam", but wouldn't really make it much more readable.
2 u/enlightment_shadow Apr 11 '26 It would
It would
Yeah I remember some old Delphi Code that I needed to check. There was no ternary operator, but like a ternary function which was called in a nested way multiple times. It was a freaking mess…
Could be worse, but assuming this is C# it should probably be converted to a switch expression.
-2
Ternary sucks
29
u/Sexy_Koala_Juice Apr 09 '26
This isn’t that bad at all
17
u/iain_1986 Apr 09 '26
I mean....is pretty readable? Depending on what "ShouldFlipH" is doing this isn't that bad.
6
u/TLStudios Apr 09 '26
You could combine the nested turnaries with "flipH() == forTeam", but wouldn't really make it much more readable.
1
u/lehrerkind_ Apr 09 '26
Yeah I remember some old Delphi Code that I needed to check. There was no ternary operator, but like a ternary function which was called in a nested way multiple times. It was a freaking mess…
1
u/Rogntudjuuuu Apr 09 '26
Could be worse, but assuming this is C# it should probably be converted to a switch expression.
-2
u/tazdraperm Apr 09 '26
Ternary sucks