Scala中的map()和flatMap()

scala> val arr = Array("My name is LittleLawson","She is Liutt")
arr: Array[String] = Array(My name is LittleLawson, She is Liutt)

scala> val result1 = arr.flatMap(_.split(","))
result1: Array[String] = Array(My name is LittleLawson, She is Liutt)

scala> val result2 = arr.map(_.split(","))
result2: Array[Array[String]] = Array(Array(My name is LittleLawson), Array(She is Liutt))

你可能感兴趣的:(#,Scala)