Open
Description
If the loop executes 0 times, then i
should be 0
; otherwise it should be greater than 0
.
function count_and_maximum(xs)
i = 0
m = 0
for (i, x) = enumerate(xs)
m = max(m, x)
end
(i, m)
end
count_and_maximum(1:5) # (0, 5) is returned, not the desired result.
I want to expose i
outside the loop but outer
doesn't work with unpacking assignment.
for outer (i, x) in enumerate(xs)
ERROR: syntax: no outer local variable declaration exists for "for outer"
for (outer i, x) = enumerate(xs)
# └──┘ ── Expected `)`
It would be nice to have some way to do this.