Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在scala中解压缩列表(list())_Scala_Nested Lists_Flatten - Fatal编程技术网

如何在scala中解压缩列表(list())

如何在scala中解压缩列表(list()),scala,nested-lists,flatten,Scala,Nested Lists,Flatten,嗨,我是scala的初学者, 我想打开行李 List(List("hello=10","hi=21","there=13","bro=44","family=44","technology=35","hi=20","hello=100","hi=21","there=13","bro=44","family=44","technology=35","hi=21","there=13","bro=44","family=44","family=44")) 变成 List("hello=10","

嗨,我是scala的初学者, 我想打开行李

List(List("hello=10","hi=21","there=13","bro=44","family=44","technology=35","hi=20","hello=100","hi=21","there=13","bro=44","family=44","technology=35","hi=21","there=13","bro=44","family=44","family=44"))
变成

List("hello=10","hi=21","there=13","bro=44","family=44","technology=35","hi=20","hello=100","hi=21","there=13","bro=44","family=44","technology=35","hi=21","there=13","bro=44","family=44","family=44")
我们怎样才能取得成功


谢谢

您可以使用内置的列表展平方法

scala> val list = List(List("hello=10","hi=21","there=13","bro=44","family=44","technology=35","hi=20","hello=100","hi=21","there=13","bro=44","family=44","technology=35","hi=21","there=13","bro=44","family=44","family=44"))
list: List[List[String]] = List(List(hello=10, hi=21, there=13, bro=44, family=44, technology=35, hi=20, hello=100, hi=21, there=13, bro=44, family=44, technology=35, hi=21, there=13, bro=44, family=44, family=44))

scala> list.flatten
res0: List[String] = List(hello=10, hi=21, there=13, bro=44, family=44, technology=35, hi=20, hello=100, hi=21, there=13, bro=44, family=44, technology=35, hi=21, there=13, bro=44, family=44, family=44)

使用
展平
方法