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

++ is an operator, !! isn't one.

Also not all uses of ++ are accepted, specially the typical memcpy() interview question, which requires to know operator precedence rules between * and ++.



!! gets weirdness points for not being a builtin operator, and ++ gets weirdness points for the subtleties of how it acts on certain things, and for being different in prefix and postfix.

I assume that's a yes to allowing ++ at all. In my opinion ++ generally does a good job of conveying intent, and !! does a very good job of conveying intent.


++ and -- are allowed as:

- single line statements always in postfix form

- for loops

- exception for the prefix form in for loops with C++ iterators due to performance reasons

Clever C code has its place in hackatons, not in code that needs to survive a few project generations.


> - exception for the prefix form in for loops with C++ iterators due to performance reasons

That is a reasonable thing to allow, but I personally find that particular use much more confusing and finicky than using !! to coerce to boolean.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: