I'm trying to populate an array of functions in Julia. A minimal example is
function nice()
i=1
while true
f() = i
produce(f)
i+=1
end
end
ye = Task(() -> nice())
funcs = Function[]
for i in [1:2]
push!(funcs,consume(ye))
println("Why does this not stay the same???")
println(funcs[1]())
end
The problem is that funcs[1] changes from the one that returns 1 to the one that returns 2! Please help me out!