我有以下代码:
var sessionIds = List[Int](12345,54321)
var Frames = List[(String, String, String, String)](("Music","Duration","Distance","Whatever"))
var someMoreFrames = List[(Int, Int, String)](1,2,"hello"))
//Do some other stuff here
var returnValue = List[(List[Int], List[(String, String, String, String)], List[(Int, Int, String)])]((sessionIds,Frames,someMoreFrames))
现在我要打印列表returnValue,我想要以下输出:
12345
54321
(Music,Duration,Distance,Whatever)
(1,2,hello)
答案 0 :(得分:6)
对于您想要的打印,您可以尝试:
returnValue.foreach { x =>
println(x._1.foreach(println) + "\n" +
x._2.foreach(println)+ "\n" +
x._3.foreach(println))
}
它会根据您的需要提供输出:
12345
54321
(Music,Duration,Distance,Whatever)
(1,2,hello)
答案 1 :(得分:0)
这应该可以解决问题:
var sessionIds = List[Int](12345,54321)
var Frames = List[(String, String, String, String)](("Music","Duration","Distance","Whatever"))
var someMoreFrames = List[(Int, Int, String)]((1,2,"hello"))
val returnValue = sessionIds ++ Frames ++ someMoreFrames
returnValue.foreach(line => println(line))