Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 Scala中扁平化一个Seq喜欢("a", "b", "c")的对象?"a,b,c"
Seq
("a", "b", "c")
"a,b,c"
以及如何从逗号分隔回来String?谢谢。
String
首先,尝试:
val seq = Seq("a", "b", "c") val string = seq.mkString(",")
对于第二个:
val parsed = string.split(",")
它返回 a Array,所以如果它必须是 aSeq那么:
Array
val parsed = string.split(",").toSeq