0
what does the oparator *= do?
i'm confused, cant find it in the corse
3 odpowiedzi
+ 1
example
x*=5 is x=x*5
+ 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.
0
thank's