Skip to content

Instantly share code, notes, and snippets.

@maowug
Created November 8, 2015 05:29
Show Gist options
  • Save maowug/fcdb28d3028c8e3984b4 to your computer and use it in GitHub Desktop.
Save maowug/fcdb28d3028c8e3984b4 to your computer and use it in GitHub Desktop.
case class Page[A](items: Seq[A], page: Int, offset: Long, total: Long) {
lazy val prev = Option(page - 1).filter(_ >= 0)
lazy val next = Option(page + 1).filter(_ => (offset + items.size) < total)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment