DEV Community

Discussion on: The Ternary Operator vs The Conditional Operator WTF

Collapse
 
andrewlucker profile image
Andrew Lucker • Edited

Ternary,+ operators are syntax sugar. The if-expression is the only one common enough to be present in most languages though.

In python: 1 < 2 < 3 or 1 < 2 < 3 < 4 expands to 1 < 2 and 2 < 3 ...

In haskell you can sort of write your own operators with n-ary syntax.

Macros also can provide n-ary syntax. React would be an example of this in Javascript+jsx.

I've got your back