LB Booster
Programming >> Language extensions >> Compound assignment operators
http://lbb.conforums.com/index.cgi?board=extensions&action=display&num=1478478151

Compound assignment operators
Post by Alincon on Nov 6th, 2016, 11:22pm

"Compound assignment operators (+=. ‑=, *=, /=) are provided. "

I would like to see some examples of using Compound assignment operators: what does += do?

Thanks
r.m.
Re: Compound assignment operators
Post by tsh73 on Nov 7th, 2016, 06:51am

Well, instead of Code:
counter = counter+1 
you write Code:
counter +=1 
.
And instantly make your code uncompatible with majority of BASIC's.
(You may not care actually - one always code "here" and "now")
Re: Compound assignment operators
Post by Richard Russell on Nov 7th, 2016, 08:21am

on Nov 7th, 2016, 06:51am, tsh73 wrote:
And instantly make your code uncompatible with majority of BASIC's.

Visual BASIC has them, BBC BASIC has them, PowerBASIC has them.... (and of course they're ubiquitous in most other programming languages like C++, Java, Python etc.).

Also bear in mind that the compound assignment operators aren't just faster to write, they execute more quickly too.

Richard.
Re: Compound assignment operators
Post by tsh73 on Nov 7th, 2016, 09:16am

Quote:
Visual BASIC has them,

I was not aware ot this, indeed.