Functions with a bang!

With the dot above, the a .= a .+ 1 is a syntax sugar for the same loop of the original function. Without the dot, a = a .+ 1 creates a new array from the result of a .+ 1 (with the elements with 1 added), but assigns that label a to this new array. The fact that the label a was “taken” does not matter here, that is equivalent to b = a .+ 1 where b is the label of the newly created array.

7 Likes