Questionable Question

The question with id 2187 struck me as odd, and after some further thinking about it the question seems to be wrong or at least too unspecific to be right.

The question:

In most programming languages, the operator ++ is equivalent to the statement “+= 1”.

Starting with the most trivial; “most” programming languages might be an exaggeration.
Just to name a few: Rust, Assembly, Python, Haskell, Lisp.
Since it is not specified to be the ++ prefix operator and no example is given, this is likely to refer to the postfix operator, which happens to be not the same since i++ and i+=1 have different return values in all languages that support the postfix ++.
Furthermore, in those languages in which they would be equivalent += must return a value (since that is the sole reason ++ even exists, doing postincrement), which makes it not a statement but an expression.

Sorry for the inconvenience, but I’m picky about features that get rejected for being awful (consider x - ++x).

3 Likes

Strong agree.