I was wondering why the following doesn't work "out of the box":
julia> for (i, c) in reverse(enumerate(["a", "b", "c"]))
print(i, c)
end
ERROR: MethodError: no method matching reverse(::Base.Iterators.Enumerate{Vector{String}})
Closest candidates are:
reverse(::Tuple) at tuple.jl:488
reverse(::Pair{A, B}) where {A, B} at pair.jl:48
reverse(::Union{SubString{String}, String}) at strings/substring.jl:166
...
Stacktrace:
[1] top-level scope
@ ./REPL[44]:1
julia> using Base.Iterators: Reverse
julia> for (i, c) in Reverse(enumerate(["a", "b", "c"]))
print(i, c)
end
3c2b1a
I am on 1.7.0-rc1
. Is this worth opening an issue or making a PR?
You can use Iterators.reverse
Last updated: Nov 22 2024 at 04:41 UTC