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
-
I love it as long as you don't chain multiple ones together, that becomes unreadable really quickly.
-
yusijs12507y@LucaScorpion i sometimes chain for simple things, but never more than one extra if. Mostly for array.sort in Javascript. I'm lazy, and doing that lets me get away without closing the lambda expression in {} 🙃
-
nicholai8937y@yusijs also you can avoid using filter, not that its bad, but because one line sexyness
arr.forEach(e => condition ? something : '') -
yusijs12507y@nicholai same with filter? arr.filter(v => v.abc ? true : false)
Unless I missed something? -
Only if the whole phrase fits in about 40 characters, and it is part of some parameterized list. Otherwise​ it should be a regular if else statement.
-
@chasb96 we're doing safety critical coding and the short form can look quite bad if misused.
It's far less ambiguous to write out the long form.
We can use the ternary operator but we have to justify it with a comment which kinda defeats the point. Even then it probably wouldn't make it through review.
My (unhealthy) obsession with the (if?then:else) shorthand syntax.
undefined
if-then-else