Skip to content

Instantly share code, notes, and snippets.

@khajavi
Created July 1, 2016 08:58
Show Gist options
  • Save khajavi/8c489e86f4fd5b666f39e5496e334c65 to your computer and use it in GitHub Desktop.
Save khajavi/8c489e86f4fd5b666f39e5496e334c65 to your computer and use it in GitHub Desktop.
object convertMapToFlatMap extends App {
val list = 1 to 10
var res1 = list map (_ * 2)
val f = (a: Int) => a * 2
val unit = (a: Int) => List(a)
val res2 = list flatMap (f andThen unit)
println(res1)
println(res2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment