Skip to content

Instantly share code, notes, and snippets.

@stanpalatnik
Created March 25, 2014 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stanpalatnik/9ef1b4baefb6847aa58b to your computer and use it in GitHub Desktop.
Save stanpalatnik/9ef1b4baefb6847aa58b to your computer and use it in GitHub Desktop.
@tailrec
def extractor[T](resultSet: ResultSet,
result: scala.collection.mutable.Builder[T, Vector[T]] = Vector.newBuilder[T])( process: ResultSet => T ): Vector[T] = {
if (!resultSet.next) result.result()
else {
val value = process(resultSet)
extractor(resultSet, result += value)(process)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment