How to change or redefine a (global?) variable from within a while loop

I think you are confusing changing the value of a global variable with changing the contents of a container. The latter operation does not change the container, only the contents.

If the above is related to this and this question, you may be better off writing a function that just modifies an array, eg

function update_foodweb!(food_web, other, arguments)
    if something
        food_web[some_coordinates, :] = updated_stuff
    end
    food_web
end
1 Like