Let's say a have two methods:
IEnumerable<int> DoSomething1();
IEnumerable<int> DoSomething2();
that modify the state of my object. I don't know if the function uses yield inside or just returns a List<int>.
And then I'd like to take the output and pass to two other functions:
void SendToUser(IEnumerable<int> values);
void PrintOut(IEnumerable<int> values);
Then just based on the function interface (DoSomethingX) I cannot say if this is a valid operation or not:
var values = DoSomethingX();
SendToUser(values);
PrintOut(values)
Because in the case of iterator it will result in calling DoSomethingX twice.
Is this some kind of inconsistency or I'm using iterator/IEnumerable in the wrong way? Where is the problem?