Source.getLines 中的默认参数错误(Scala 2.8.0 RC1) [英] Error with default argument in Source.getLines (Scala 2.8.0 RC1)

查看:49
本文介绍了Source.getLines 中的默认参数错误(Scala 2.8.0 RC1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

assuming I running Scala 2.8.0 RC1, the following scala code should print out the content of the file "c:/hello.txt"

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

但是,当我运行它时,出现以下错误

However, when I run it, I get the following error

<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 中的错误

From what I understand, Scala should use the default argument "compat.Platform.EOL" for "getLines". I am wondering if I did wrong or is it a bug in scala 2.8

谢谢

推荐答案

改为编写 getLines(),以便使用默认值.

Write getLines() instead, so that the default gets used.

这篇关于Source.getLines 中的默认参数错误(Scala 2.8.0 RC1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆