Skip to content

Instantly share code, notes, and snippets.

@hugolu
Created February 24, 2016 01:34
Show Gist options
  • Save hugolu/55c1e16df4a0972a1c1d to your computer and use it in GitHub Desktop.
Save hugolu/55c1e16df4a0972a1c1d to your computer and use it in GitHub Desktop.
val list = List(1, 2, 3) //> list : List[Int] = List(1, 2, 3)
list.map(_.toString).mkString(", ") //> res0: String = 1, 2, 3
val map = Map(1 -> "A", 2 -> "B", 3 -> "C") //> map : scala.collection.immutable.Map[Int,String] = Map(1 -> A, 2 -> B, 3 -> C)
map.map(_ match { case (k, v) => k + ":" + v }).mkString(", ")
//> res1: String = 1:A, 2:B, 3:C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment