• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

=+ operator

 
Ranch Hand
Posts: 40
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Mala Gupta's SE 7 book, it said that =+ didn't exist, but I just tested it and it compiled and ran fine.
Is this a typo or something else?
 
author
Posts: 23836
140
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Well, what did you do? Did you do something like this?



If so, then it is *not* an "=+" operator. It is two operators. You are doing an assignment, where the RHS is going through an unary plus operation.

Henry
 
Ranch Hand
Posts: 99
15
Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric,

please don't be confused. There is a difference between a += and =+
The first one is an assignment operator:

The second example means, as Henry says, two operators. An assignment operator = and an unary operator +.
You can rewrite it like this:

so you can omit the + sign and write

The second example makes more sense if you need to write

So you negate the 10 first and assign the result to a;
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!