Skip to content

Instantly share code, notes, and snippets.

@ripla
Created July 7, 2015 12:29
Show Gist options
  • Save ripla/9cb2f3616d80866a303c to your computer and use it in GitHub Desktop.
Save ripla/9cb2f3616d80866a303c to your computer and use it in GitHub Desktop.
Creating infinite streams from a function
//Get a new Stream that always calls the given function when a new value
//is needed.
def stream(): Source[Int, Unit] =
Source(() => Iterator.continually(createValue()))
//Just an example, could be anything
def createValue(): Int = Random.nextInt()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment