if I do this in Java:
for(String s : myCollection.expensiveListGeneration()) { doSomething(); }
is expensiveListGeneration() invoked
because it is equivalent to using an iterator, it is equivalent to calling the collections' . iterator() method, and it is called once.