Skip to content

Instantly share code, notes, and snippets.

@khajavi
Created November 27, 2015 16:46
Show Gist options
  • Save khajavi/552e5d6e9339a04623d0 to your computer and use it in GitHub Desktop.
Save khajavi/552e5d6e9339a04623d0 to your computer and use it in GitHub Desktop.
recursive last in scala
def last[A](xs:List[A]): A = xs match {
case x :: Nil => x
case _ :: tail => tail last
case _ => throw new NoSuchElementException
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment