3 ms·
Do you use ++? I don't see !! as any weirder.
by Dylan16807 11y ago
Do you use ++? I don't see !! as any weirder.
- pjmlp 11y ago++ 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 ++.
- Dylan16807 11y ago!! 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.
- pjmlp 11y ago++ 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.
- Dylan16807 11y ago> - 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.