Definition : The Iterator pattern represents access to all elements of a compound object, without revealing its internal representation.

What is meant by " without revealing its internal representation "?

I would like to see an example when an open view and a closed one.

    1 answer 1

    A classic example is List<T> . Inside it contains essentially an array in which the last few elements are not used. But outside the array is not visible. You can bypass it through foreach (which uses an iterator inside), get all the elements of the list, but you will not see the internal array.

    On the other hand, List<T> could be implemented differently, it could put its supporting array out, and it would be necessary to iterate over the array. Then he would have revealed the inner concept.