To save typing, and to make your code a bit neater, you can combine assignment with one of the operators:
+ - / * &For example, instead of saying:
mylongvarname = mylongvarname + 1You can say:
mylongvarname += 1Instead of saying:
galaxy[q_row][q_col][q_size] = galaxy[q_row][q_col][q_size] * 10You can say:
galaxy[q_row][q_col][q_size] *= 10and instead of saying:
accounts[start..finish] = accounts[start..finish] / 10You can say:
accounts[start..finish] /= 10In general, whenever you have an assignment of the form:
left-hand-side = left-hand-side op expressionYou can say:
left-hand-side op= expressionwhere op is one of: + - * / &
When the left-hand-side contains multiple subscripts/slices, the op= form will usually execute faster than the longer form. When you get used to it, you may find the op= form to be slightly more readable than the long form, since you do not have to visually compare the left-hand-side against the copy of itself on the right side.
Note the explicit assignment ':=' operator does not have any assignment with operator forms since the latter are already explicit assignment operations anyway.