3 ms·
How is that better than the C# solution of just making the subroutine return an IEnumerable, then yielding its elements in the calling function? (aside from may
by jcparkyn 3y ago
How is that better than the C# solution of just making the subroutine return an IEnumerable, then yielding its elements in the calling function? (aside from maybe marginally better perf characteristics)?
- anonymoushn 3y agoIt works with subroutines that don't know anything about iterators or yielding but do know about first-class functions. It's also less boilerplate, since there isn't a `yield from`, I guess.
- agent281 3y agoIt seems like a different kind of boilerplate: instead the functions need to take a yield so you are threading the function through you program. I don't know if it's better to expect a return type or to force a function argument. I lean towards the former, but that might be because of familiarity.