I have the following
julia> Base.collect(::Base.Generator{MyCollection}) = print("success")
julia> [x for x in MyCollection([1,2])]
success
I can’t figure out how Julia goes from parsing the comprehension [x for x in MyCollection([1,2])]
to calling Base.collect(::Base.Generator{MyCollection})
. Is this done via an undocumented operator with a special name, just like [A B C] results in a call to Julia function hcat
? In other words, does [x for x in ...]
directly result in a call to Base.collect(::Base.Generator)
or are there a few steps in between?
Any suggestions?