Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
TobiSGD2816yDepends on the language.
I personally don't think that
if a:
x = y
else:
x = z
is inherently more readable than
x = y if a else z
Of course that is Python and readability is somewhat inbuilt in that language. -
@david-hil as long as you don't nest ternaries like a madman they tend to be more readable than if/else
-
@desirous I have no problem with reading them. Don't be so condescending.. It's not a good look.
Complex operations should be broken out so the logic is simpler to follow. That's my point. Easier to read, less of a headache to maintain. -
Fenix5986yI prefer to write them on three lines if they are a bit more complex and find them better to read :)
-
@desirous the code I'm referring to has nested linq statements in ternary form. I had to break it into several lines to make it readable, because the guy felt it necessary to put it all on one line.
Just because you can do things in one line and throw in ternary operators everywhere, doesn't mean you should.. other people will touch your code. Make it readable instead of making it harder to maintain
rant