Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    There are already other answers here that have and iterator, and do it much better. It takes all of 4 lines of code to write an iterator for a linked list, not all of the code you have here. Commented Feb 14, 2017 at 16:45
  • Can you show me the four lines? What do you think is much better? Commented Feb 14, 2017 at 17:14
  • Ok. Thanks for the help - you troll me and respond with nothing specific. I see one answer implementing IEnumerable that uses yield return. Is that better? Is that answer simpler? I'll let others be the judge. Commented Feb 14, 2017 at 17:21
  • I for one found it confusing... esp. since the OP clearly asked for simple, clear implementation. The iterator using yield IS much clearer, and simpler, and the standard way to support iteration. Commented Jul 3, 2017 at 16:55
  • Ok, sure. But it's how you implement an iterator. I think you point out why the yield keyword was introduced. To me, however, it's clearer to see it explicitly. But use a keyword if you think that's simpler. Commented Jul 3, 2017 at 17:47