Skip to content

Instantly share code, notes, and snippets.

@nuttycom
Created October 2, 2013 18:20
Show Gist options
  • Save nuttycom/6798180 to your computer and use it in GitHub Desktop.
Save nuttycom/6798180 to your computer and use it in GitHub Desktop.
implicit class MaxBy[A](t: (A, A)) {
def maxBy[B: Order](f: A => B) =
(Order[A].order _).tupled(t umap f) match {
case GT | EQ => t._1
case LT => t._2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment