top | item 40960254

(no title)

doctor_eval | 1 year 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.

discuss

order

pansa2|1 year ago

In C#, `yield` is a kind of return, not a function call. The two approaches to iteration are quite different (external vs internal iteration).

pjmlp|1 year ago

No, before C# got generators, some of the machinery had to be manually implemented, with yeld, the compiler generates the necessary implementation for IEnumerable.