I have a question about a program that includes the following if statement:
if (x =+ 4){ x += 5; }
I have never seen anything like this before, of course, is this not a typo? Does = + actually do something?
x =+ 4
means
x= (+4)
or simply
x=4
although such a construction is syntactically correct and can be compiled, it does not make much sense and most likely typos where it was intended x==4, especially since it is used as a condition forif
x==4
if
In the early days of C, it =+was the same as it was +=, but so long ago it left and never made its way into C ++.
=+
+=
=+a understood as = (+a)
=+a
= (+a)
+ int, , no-op.
+
int
= .
=
=+ = :
= , { Foo, int} {Foo, char}, Foo Foo a char c,
Foo
char
char c
foo = c // calls the overload taking a `char`
foo =+ c // calls the overload taking an `int`
.
, .
: x 4, , if 5.
:
x = 9;
, , if x == 4, x += 4, x != 4 .
x == 4
x += 4
x != 4
, , , : = + = - + = - = op:
: = + C? https://www.cs.auckland.ac.nz/references/unix/digital/AQTLTBTE/DOCU_064.HTM ( -!)
, ,
https://en.wikipedia.org/wiki/C_(programming_language)#K.26R_C
tells us that they were changed: "The auxiliary form assignment operators = op (for example, = -) were changed to the form op = (i.e. - =) to remove the semantic ambiguity created by constructs such as I = -10, which was interpreted as i = -10 (decreasing i by 10) instead of the expected i = -10 (let me be -10). "
So this is not related to the explicit expression of the argument + ve or -ve. You can simply replace modern forms, for example, use + = instead of = +.
Source: https://habr.com/ru/post/1656397/More articles:Circular dependency between tasks testCompiler - gradle"[Errno 2] There is no such file or directory" when trying to backup the database in pgAdmin4 - pgadmin-4How do I know if a URL is decoded / encoded? - javascriptAndroid set view position - setY vs setTop - javaFirebase limitToLast Query - androidChanging spark configuration at run time - configuration-filesWhy the dictionary does not implement Add (KeyValuePair) - dictionaryFinding the sum of subarrays - javascriptCan I change the user npm? - githubФормат Excel VBA (, "mmmmm-yy" ) не работает должным образом - vbaAll Articles