Additional Assignment Operators

In Python, x += 3 is the same as x = x + 3. Is there something equivalent in Xojo?

Unfortunately not. There’s a very old Feedback Case for additional assignment operators, but I can’t find it right now.

A long time ago, created a Reformat Code Script that can change code formatting on the fly. It does include the one you specified. It is still available at Reformat Code on github. Be sure to look over the Readme file.

I use Keyboard Maestro with a trigger on “≠≠” (that’s option+plus+plus on the Mac) that will turn this x ≠≠ into this x = x + 1.

There is quite the debate on whether to include those assignment operators natively, and I’m in the “no” camp.

1 Like

I would be interested to know your thoughts on this. It would seem to me that it would make the code a bit more compact and easier to type. Less repetition means less potential for errors, no?

Nope, nope, nope, not going to get into this. Let’s talk about something less divisive, like religion or politics. :slight_smile:

8 Likes