Skip to content

Instantly share code, notes, and snippets.

@danistrebel
Created October 13, 2015 13:07
Show Gist options
  • Save danistrebel/9de92f9eb6f6d86249a6 to your computer and use it in GitHub Desktop.
Save danistrebel/9de92f9eb6f6d86249a6 to your computer and use it in GitHub Desktop.
Seq("a", "b", "c", "d") => "a, b, c or d"
def orJoin(list: Seq[String]) = {
(list.reverse match {
case last::secondToLast::rest => (s"$secondToLast or $last"::rest).reverse
case _ => list
}).mkString(", ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment