Posts Tagged iterator

Getting the Result of an Iterator

Tags: , , ,

Iterators (functions that yield) are great for representing asynchronous processes such as web calls, updating state over time, and multi-step operations. One unfortunate downside is that it’s tough to return a result from them. Today’s article explores several workarounds to this problem before ultimately arriving at a clean, easy-to-use solution to the problem. Read on to learn how to make iterators more useful!

Read the rest of this article »

No Comments

Working Around Iterator Function Limitations

Tags: , , , ,

As you use iterator functions (and yield) more and more, you’ll start to run into some limitations in the C# language. For instance, you can’t yield inside a try block that has a catch block. And the foreach loop doesn’t provide a very good way to catch exceptions when looping over an iterator function, either. Today’s article goes into detail to find solutions to these issues and make iterator functions usable in even the trickiest scenarios!

Read the rest of this article »


From AS3 to C#, Part 17: Conditionals, Exceptions, and Iterators

Tags: , , , , , , , , ,

Continuing the series on C# syntax, today we’ll look at the differences an AS3 programmer can expect to encounter when using conditionals (if/else, switch/case/break/goto) and exceptions (try/catch/finally/throw). We’ll also look at iterators, an all-new category for AS3 programmers that empowers us to both iterate however we want and to write coroutines, a kind of lightweight pseudo-thread.

Read the rest of this article »