TAMTOWTDI

The followings are equivalent.

  • if ($x == 0) {$y = 10;} else {$y = 20;}
  • $y = $x==0 ? 10 : 20;
  • $y = 20; $y = 10 if $x==0;
  • unless ($x == 0) {$y=20} else {$y=10}
  • if ($x) {$y=20} else {$y=10}
  • $y = (10,20)[$x != 0];

Leave a Reply