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

>then it exactly mirrors the if/else-if/else structure.

But it doesn't mirror the if/else-if/else structure. Rather the mirrored semantics looks as follows:

  if(a < b)
    return -1;
  else 
    if(a > b)
      return 1;
    else
      return 0;
It's interesting that for all the claims in this thread about how obvious the ternary operator is, almost every single person got it wrong.

Is there a functional difference in this example? No. There isn't. Is there a functional difference in any example? I don't think so, but I'm not 100% sure. And the nice thing about not being clever, I don't have to worry about it.



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

Search: