# ScatterNNlib: array mutation not supported

**URL:** <https://discourse.julialang.org/t/scatternnlib-array-mutation-not-supported/55004>\
**Category:** General Usage\
**Created:** [February 10, 2021, 3:44pm UTC](https://discourse.julialang.org/t/scatternnlib-array-mutation-not-supported/55004 "2021-02-10T15:44:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeepQ](https://avatars.discourse-cdn.com/v4/letter/d/2bfe46/32.png) [@DeepQ](https://discourse.julialang.org/u/DeepQ)\
**Post date:** [February 10, 2021, 3:44pm UTC](https://discourse.julialang.org/t/scatternnlib-array-mutation-not-supported/55004/1 "2021-02-10T15:44:32Z")

</div>

I know that Zygote.jl doesn’t support array mutation. I tried to use `ScatterNNlib.gather` but It shows array mutation error:

```julia
using Flux
using ScatterNNlib

f(x) = gather(x, [1 3; 4 2], 2)
gradient(x -> f(x), rand(4,4))

```

Let us look at `ScatterNNlib.gather`:

```julia
function gather(input::AbstractArray{T,N}, index::AbstractArray{<:Integer,N}, dims::Integer) where {T,N}
    @assert dims <= N "Specified dimensions must lower or equal to the rank of input matrix."
    out = similar(index, T)
    @inbounds for x = CartesianIndices(out)
        tup = collect(Tuple(x))
        tup[dims] = index[x]
        view(out, x) .= view(input, tup...)
    end
    return out
end

```

Why does this line mutates an array? Where is `Zygote.Buffer`?  
`view(out, x) .= view(input, tup...)`
