Collect() requires length() for iterators?

Hi all,

I’m getting a method error when calling collect on an iterator on 0.6. Is this expected?

julia> type Iterable x::Float64 end
julia> Base.start(x::Iterable) = 0
julia>, state) = (0, state+1)
julia> Base.done(x::Iterable, state) = state == 1
julia> collect(Iterable(0))
ERROR: MethodError: no method matching length(::Iterable)
1 Like

Base.iteratorsize(::Type{Iterable}) = Base.SizeUnknown()

It defaults to Base.HasLength(). See for discussion about that default.

1 Like

thx. This must have changed between 0.4 and 0.6 which is why my old code is failing.