Thursday, 5 September 2013

Why is my companion object cannot access method in its companion class

Why is my companion object cannot access method in its companion class

I am new to Scala. I read that the companion object can access companion
class's method. I have the following code:
class MinPath {
def minPath(input : List[List[Int]], tempResult : List[List[Int]],
currentlevel : Int) : List[List[Int]] = {
....
}
}
object MinPath {
....
def main(args : Array[String]) = {
// This has an compile error
val transformed = minPath(input, List(List()), 0)
}
}
They are defined in the same file called MinPath.scala.
But the minPath used in the object causes an compile error as it cannot
find the minPath.
I am wondering what did I do wrong here?

No comments:

Post a Comment