Created
July 1, 2016 08:58
-
-
Save khajavi/8c489e86f4fd5b666f39e5496e334c65 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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