Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created July 24, 2011 09:35
Show Gist options
  • Save kmizu/1102444 to your computer and use it in GitHub Desktop.
Save kmizu/1102444 to your computer and use it in GitHub Desktop.
Iterator#map (Scala 2.8.0.final and Scala 2.7.7.final)
def map[B](f: A => B): Iterator[B] = new Iterator[B] {
def hasNext = Iterator.this.hasNext
def next() = f(Iterator.this.next)
}
def map[B](f: A => B): Iterator[B] = new Iterator[B] {
def hasNext = self.hasNext
def next() = f(self.next())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment