what does the oparator *= do? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what does the oparator *= do?

i'm confused, cant find it in the corse

31st Dec 2016, 6:32 PM
Shmuel
3 Answers
+ 1
example x*=5 is x=x*5
31st Dec 2016, 6:39 PM
Leonida17st
Leonida17st - avatar
+ 1
As Leo says, the *= operator makes you multiply anything following the operator by the leading variable, and returning it. It's useful to shorten the otherwise longer operation, but it is in no way necessary to remember, as it only shortens already existing syntax. An example of use would be multiplying the current value of a variable by another value. With *= operator: int customers = 10; int purchasesForCustomer = 3; customers *= purchasesForCustomer; Without *= operator: int customers = 10; int purchasesForCustomer = 3; customers = customers * purchasesForCustomer; As you can see, with longer variable identifiers, it can shorten the line length considerably.
31st Dec 2016, 6:56 PM
Dao
Dao - avatar
0
thank's
31st Dec 2016, 8:42 PM
Shmuel