Why FOR Loop last iteration ITEM not available GLOBALLY?

Sure

julia> for i in 1:10
           global outeri = i
           i>5 && break
       end

julia> outeri
6

As for why - it’s a design decision to make loops have their own scope. It takes some getting used to coming from python, but it ultimately leads to better practice.

Edit: ahh you beat me to it!

2 Likes