Link Details

Vote up, vote down. It doesn't matter which - just vote! Login and vote now.
Link 71278 thumbnail
User 111696 avatar

By bloid
via php.dzone.com
Published: Mar 18 2008 / 14:14

I started using ternary operator logic about six months ago and notice myself using shorthand if/else logic all the time. It shortens my code, the time to write it, and makes me look smarter to the mustaches.
  • 12
  • 2
  • 1078
  • 440

Comments

Add your comment
User 249616 avatar

robse replied ago:

0 votes Vote down Vote up Reply

ghastly ternary operator

User 59996 avatar

sky_HALud replied ago:

0 votes Vote down Vote up Reply

The ternary operator has been one of the most confusing language constructs since the days of C. And I'm sure it wasn't meant to be nested! Just because it looks cool it doesn't mean that you should overuse it (hammer, nail - use them for everything).

As a side note, I recently took a close look on the code of phpBB 2 and that of nBB 2. One of the reasons why the code is so horrible is because ternary operators are overused. Another reason is the underuse of functions ("dump that thousand lines of code right in the page!").

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.