对于以下代码:
package FileOperations
import java.net.URL
object FileOperations {
def processWindowsPath(p: String): String {
"file:///" + p.replaceAll("\\", "/")
}
}
Run Code Online (Sandbox Code Playgroud)
编译器给出错误:
> scalac FileOperations.scala
FileOperations.scala:6: error: illegal start of declaration
"file:///" + p.replaceAll("\\", "/")
Run Code Online (Sandbox Code Playgroud)
为什么?怎么修?
Jon*_*ffe 22
您从processWindowPath方法声明中缺少一个=.
package FileOperations
import java.net.URL
object FileOperations {
def processWindowsPath(p: String): String = {
"file:///" + p.replaceAll("\\", "/")
}
}
Run Code Online (Sandbox Code Playgroud)
object FileOperations {
def processWindowsPath(p: String): String = {
"file:///" + p.replaceAll("\\", "/")
}
}
Run Code Online (Sandbox Code Playgroud)
有一个失踪=.Scala中的方法以这种方式定义:
def methodName(arg1: Type1, arg2: Type2): ReturnType = // Method body
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10679 次 |
| 最近记录: |