Created
October 13, 2015 13:07
-
-
Save danistrebel/9de92f9eb6f6d86249a6 to your computer and use it in GitHub Desktop.
Seq("a", "b", "c", "d") => "a, b, c or d"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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