我只想弄清楚像List这样的不可变的东西是如何工作的,以及我如何为它添加东西?
我很抱歉问这些愚蠢的问题,但是为什么我的列表在打印时总是空的?
var end = false
val list = List()
while (!end) {
val input = scala.io.StdIn.readLine("input:")
if (input == "stop" ) end = true
else input :: list
}
println(list)
}
Run Code Online (Sandbox Code Playgroud)
很抱歉给我带来不便和这个相当愚蠢的问题!