Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's basically the same syntax but with keywords. How is it 'much better'? And if you're doing something complex like nested ternary (please don't) you can use () to mark sections just as well as your method uses {} to mark sections.


it's better because 1) it falls out of the regular semantics of the language. it's just a regular if expression. it's a consequence of a more elegant and unified design, in other words. that ternary syntax by comparison is ad-hoc. to begin with, it's the only ternary operator in those kinds of languages. (thus people call it "the" ternary operator). it shows poor design restraint, imo

2) it's not punctuation. a ternary expression is a 3-input mapping to begin with. punctuation only makes it noisier.


>nested ternary (please don't)

Eh, if you use whitespace effectively it is perfectly readable. Moreso than the alternative, IMO.


Yep. My thinking exactly. Easiest thing to read is a table. Always :)


A table is fine, but the equivalent of 'else if' isn't true nesting. I meant making an elaborate tree, which should not be squished into a single statement unless you have a really good way of organizing it.


That's what I meant, as well :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: