I’m having trouble to understand the following behavior of Iterators.Stateful. This is as expected
julia> for a in Iterators.Stateful([1,2,3])
print(a)
end
123
But this seems strange:
julia> [a for a in Iterators.Stateful([1,2,3])]
2-element Array{Int64,1}:
1
2
julia> [a for a in Iterators.Stateful([1])]
ERROR: BoundsError: attempt to access 0-element Array{Int64,1} at index [1]
Is this a bug, or is there something I don’t understand here?