Suppose I have a function (usually, but not necessarily a constructor) with signature myfun(xs...)
and I want it to be able to take a generator, eg myfun(something(x) for x in itr)
. An example of this style in Base
is Dict
.
What is the recommended way of writing this in 0.6? The cheap way out is
myfun(xs::Base.Generator) = myfun(xs...)
but I don’t think that is optimal. Looking at the source of Base.Dict(kv)
, I see that first it tries associative_with_eltype
and then fails with a nice error message if that is not applicable. So is Base.associative_with_eltype
the way to go if I want similar functionality?