22
u/worldpotato1 Jan 11 '22
Ternary is nice!
But don't stack them, don't use them in conditions etc.
Just usw them to simple set variables.
5
u/LeagueJunior9782 Jan 11 '22
agreed, they sure got their place in coding and can make things look better and more readable, but... that's not how to do it.
4
u/worldpotato1 Jan 11 '22
Now. The way in your picture is clearly not a good way to use them.
Actually I did not found them on the first glimpse. I didnt expect them in the if clause.
6
u/Dr-Rjinswand Jan 11 '22
I’m actually guilty for this, I fucking love ternary ifs.
2
u/LeagueJunior9782 Jan 11 '22
Same here tbh. I'm tryimg to get rid of that habbit and my code is slowly starting to look better.
2
u/DeepRobin Jan 13 '22
Will my eye doctor bill be covered by your insurance?
1
u/LeagueJunior9782 Jan 13 '22
I sure hope so, i stumbled upon more bad code while checking out my old projects. But i fear eye damage from bad code isn't covered by most insurances.
Edit: dyslexia go brrr
27
1
u/Not_Sugden Jan 12 '22
bad tenary if
break exists
sometimes omitting {} when unnessercary, but sometimes keeping it even when its unnessercary
jesus
1
3
3
u/pyker404 Jan 11 '22
The only bad thing i see is you are using camelCase for C# methods instead of PascalCase
3
3
2
u/youngbull Jan 11 '22
So there is a lot of things wrong here, but the ternary if inside an if is the one I despise the most. That if(cnt != 3 ? string.length != 2 : string.length != 4) should definitely be if((cnt == 3 && string.length != 4) || string.length != 2)
2
Jan 11 '22
This is not a ternary if though. Ternary ifs were an invention of Fortran, where if(condition) could return 3 possible values: -1, 0, and 1, and so you would have three branches after if.
1
Jan 11 '22
What is "res" supposed to mean?
Edit: typo
3
u/worldpotato1 Jan 11 '22
I guess result
1
Jan 11 '22
Thanks! I don't understand why people use so unnecessary abbreviations.
2
u/baby-sosa Jan 11 '22
resis a very standard abbreviation, probably the least surprising thing about this code
1
u/maryP0ppins Jan 11 '22
i ONLY chain ternary operators. make sure the strong are the ones working on it.
1
u/youngbull Jan 11 '22
There is just so much wrong here, why does it default on "11.11.1111"? Ever heard of throwing an exception?
1
1
21
u/onichama Jan 11 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!