Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Why is =+ (equals plus) valid in Apex?

Asked by Ranjana Admin Apr 24, 2021 861 views 1 answer
Share

About this question

Just fixed an unfortunate bug. I was trying to concatenate a string. But it kept getting replaced by the string it should have been adding. Couldn't figure it out for a while.

I was doing the operation like this:

attendeesListFormatted =+ attendeeFormated;

Took me a while to see my dyslexic mistake. Then I wondered why is that valid? Wouldn't it encounter an unexpected character after the assignment?

Then it occurred to me that maybe Apex was treating it as a null concatenation. Like so:

attendeesListFormatted = '' + attendeeFormated;

Can anyone think of another reason my mistake wouldn't throw an #error!

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.