2010-04-28 3 views
4

의 기본 인수에 오류가 있습니다. 다음 스칼라 코드는 "c : /hello.txt"파일의 내용을 인쇄해야합니다.Source.getLines (Scala 2.8.0 RC1)

나는 그것을 실행할 때
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 

내가 이해에서, 스칼라는 "getLines"에 대한 기본 인수 "compat.Platform.EOL"를 사용합니다. 내가 잘못했다거나 기본값이 사용됩니다 있도록이 대신 2.8

감사

답변

5

스칼라의 버그 쓰기 getLines() 있는지 궁금하고있다.

4

Daniel이 말했듯이 컴파일 할 때 메서드 이름 뒤에 괄호를 써야합니다. 메서드 정의에 괄호가 포함되어 있으면이를 호출 할 때 괄호를 사용해야합니다. 아마도 메소드의 모든 인수에 기본값이있는 경우에도이 값은 계속 유지됩니다 (여기에서와 같이).

관련 문제