Skip to content

Instantly share code, notes, and snippets.

@huynhjl
huynhjl / gist:599089
Created September 27, 2010 14:10 — forked from kbloom/gist:580157
Generators with continuations
import scala.util.continuations._
class Generator[A] extends Iterator[A] with (A => Unit @ suspendable) {
private var a: Option[A] = None
private var k: Option[Unit => Unit] = None
def next = {
val a0 = a.get
val k0 = k.get
a = None