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

Interesting C++ tidbit: the ternary operator can yield an lvalue, like so:

  int foo = 0, bar = 0;
  (cond ? foo : bar) = 8;
This doesn't work in plain C.


But it does with pointers in C:

  int foo = 0, bar = 0;
  *(cond ? &foo : &bar) = 8;




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: