how to format multiple conditions assignments in return statement [CLOSED] [Answered]
Greetings, I was wondering, how could I properly format this piece of code.
You can see I tried to format it somehow, but I don't think it looks good. :D
11 Replies
the way you format that is by changing it to if/if else/else
my eyes are crossing just trying to read that
I thought that cond assign is faster than if else in most cases
no
there's no perf difference
not sure where you got that idea from
I saw it somewhere, but it was with strings, not ints
that's why probably
still doesn't make a difference
and it was in cpp
just change to regular if statements
wouldn't be different there either
The Cherno
YouTube
Ternary Operators in C++ (Conditional Assignment)
Patreon ► https://patreon.com/thecherno
Twitter ► https://twitter.com/thecherno
Instagram ► https://instagram.com/thecherno
Slack ► https://slack.thecherno.com
Discord ► https://discord.gg/R2t97wf
Series Playlist ► https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb
Gear I use:
-----------------
BEST laptop for programmin...
that's due to a quirk of how C++ handles declarations
and would perform exactly the same
also that nested ternary in the video is an unreadable abomination
the guy in the video is trying to be really clever
but in a bad way
don't be "clever" like that, you'll hate yourself down the line
well he's not exactly one of my favourites
okay thanks for help
✅ This post has been marked as answered!