The for loop starts by calling your makeIterator() under the covers and then mutates that iterator, leaving your original box instance unchanged.
The while loop is doing basically the same thing, except the makeIterator() call is explicit. If you changed that loop to print fib.currentIndex instead of iter.currentIndex then you would get the same output as the for loop.
Topic:
Programming Languages
SubTopic:
Swift
Tags: