gpt4 book ai didi

scala - Source.getLines 中的默认参数错误(Scala 2.8.0 RC1)

转载 作者:行者123 更新时间:2023-12-04 23:10:05 25 4
gpt4 key购买 nike

假设我运行 Scala 2.8.0 RC1,下面的 Scala 代码应该打印出文件“c:/hello.txt”的内容

for ( line<-Source.fromPath( "c:/hello.txt" ).getLines )    
println( line )

但是,当我运行它时,出现以下错误
<console>:10: error: missing arguments for method getLines in class Source;
follow this method with `_' if you want to treat it as a partially applied function
Error occured in an application involving default arguments.
val it = Source.fromPath("c:/hello.scala").getLines

据我了解,Scala 应该对“getLines”使用默认参数“compat.Platform.EOL”。我想知道是我做错了还是 Scala 2.8 中的错误

谢谢

最佳答案

写信 getLines()相反,以便使用默认值。

关于scala - Source.getLines 中的默认参数错误(Scala 2.8.0 RC1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2732487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com