Unexpected map! behaviour

In map!(x ->x*2, a[1,:], [1,2,3]) you are not modifying a. a[1, :] returns a new vector which you put the result in. It is equivalent to

a = zeros(2, 3)
tmp = a[1, :]
map!(x->x*2, tmp, [1, 2, 3])

so you are only modifying tmp. You can use a view if you want your output vector to point to the same memory as a, e.g.

map!(x->x*2, @view(a[1,:]), [1, 2, 3])

See also PSA: how to quote code with backticks

3 Likes