I'm not entirely sure why, but it works if you assign an anonymous closure to f:
f = () -> j This also requires the let block. On Monday, February 16, 2015 at 1:27:56 PM UTC-5, Stepa Solntsev wrote: > > I tried, it still doesn't work. > > function nice() > i=1 > while true > let j=i > f() = j > produce(f) > end > i+=1 > end > end > ye = Task(() -> nice()) > funcs = Function[] > for k in [1:2] > push!(funcs,consume(ye)) > end > > println(funcs[1]()) > println(funcs[2]()) > >
