Yes, exactly.
The iteration state is something that is passed to the next time iterate is called - it’s specific to each iterable. In the case of a tuple, it’s just the index of the next element in the tuple.
julia> a = "AAAGCTAGCTAGCTAGACT"
"AAAGCTAGCTAGCTAGACT"
julia> b = "ATAGCTAGCCAGCTAAACT"
"ATAGCTAGCCAGCTAAACT"
julia> tup = (a,b)
("AAAGCTAGCTAGCTAGACT", "ATAGCTAGCCAGCTAAACT")
julia> iterate(tup)
("AAAGCTAGCTAGCTAGACT", 2)
julia> iterate(tup, 2)
("ATAGCTAGCCAGCTAAACT", 3)
julia> iterate(tup, 3) # returns `nothing`, indicating the end of the iteration
The iteration state is arbitrary though, so it can be anything you’d like it to be for your own type.
Yes. You’re literally creating a tuple of three strings by writing (a,b,c). Since loops have their own scope, your loop variable str shadows the existing str variable outside of the loop. So the str in your loop first is a, then b, then c.