Hacker News new | past | comments | ask | show | jobs | submit login

https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

> Unlike (literally!) every other language with a similar operator, ?: is left associative. So this:

  $arg = 'T';
  $vehicle = ( ( $arg == 'B' ) ? 'bus' :
               ( $arg == 'A' ) ? 'airplane' :
               ( $arg == 'T' ) ? 'train' :
               ( $arg == 'C' ) ? 'car' :
               ( $arg == 'H' ) ? 'horse' :
               'feet' );
  echo $vehicle;
> prints horse.

In what world is this sane language design?!




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

Search: