6 ms·
Isn’t the only real difference that the yield function is being passed into the iterator instead of being a reserved word? I don’t think it’s clunky, although i
by doctor_eval 2y ago
Isn’t the only real difference that the yield function is being passed into the iterator instead of being a reserved word? I don’t think it’s clunky, although it took a few minutes for me to get it.
- pjmlp 2y agoNo, before C# got generators, some of the machinery had to be manually implemented, with yeld, the compiler generates the necessary implementation for IEnumerable.
- pansa2 2y agoIn C#, `yield` is a kind of return, not a function call. The two approaches to iteration are quite different (external vs internal iteration).