Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The difference between += and =+

People also ask

What is the difference between single and double quotation marks?

General Usage Rules In America, Canada, Australia and New Zealand, the general rule is that double quotes are used to denote direct speech. Single quotes are used to enclose a quote within a quote, a quote within a headline, or a title within a quote.

What is the difference between single and double inverted commas?

Double quotation marks (in British English) are used to indicate direct speech within direct speech (use single inverted commas for direct speech and double quotation marks to enclose quoted material within).

What are single quotation marks used for?

Single quotation marks are also known as 'quote marks', 'quotes', 'speech marks' or 'inverted commas'. Use them to: show direct speech and the quoted work of other writers. enclose the title of certain works.

What's the difference between quotation marks and apostrophes?

But I bet you're curious about how they're different, why else would you be here? The main difference between the two is: Quotation marks are used to report speech. An apostrophe is used for making contractions and possession.


a += b is short-hand for a = a + b (though note that the expression a will only be evaluated once.)

a =+ b is a = (+b), i.e. assigning the unary + of b to a.

Examples:

int a = 15;
int b = -5;

a += b; // a is now 10
a =+ b; // a is now -5

+= is a compound assignment operator - it adds the RHS operand to the existing value of the LHS operand.

=+ is just the assignment operator followed by the unary + operator. It sets the value of the LHS operand to the value of the RHS operand:

int x = 10;

x += 10; // x = x + 10; i.e. x = 20

x =+ 5; // Equivalent to x = +5, so x = 5.

+= → Add the right side to the left

=+ → Don't use this. Set the left to the right side.


a += b equals a = a + b. a =+ b equals a = (+b).


x += y 

is the same as

x = x + y

and

x =+ y

is wrong but could be interpreted as

x = 0 + y