For the following code:
package FileOperations
import java.net.URL
object FileOperations {
def processWindowsPath(p: String): String {
"file:///" + p.replaceAll("\\", "/")
}
}
Compiler gives an error:
> scalac FileOperations.scala
FileOperations.scala:6: error: illegal start of declaration
"file:///" + p.replaceAll("\\", "/")
Why? How to fix?
You're missing an = from the processWindowPath method declaration.
package FileOperations
import java.net.URL
object FileOperations {
def processWindowsPath(p: String): String = {
"file:///" + p.replaceAll("\\", "/")
}
}
object FileOperations {
def processWindowsPath(p: String): String = {
"file:///" + p.replaceAll("\\", "/")
}
}
There is a missing =
. Methods in Scala are defined this way:
def methodName(arg1: Type1, arg2: Type2): ReturnType = // Method body
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With