Reputation: 497
I am trying to run this program but it is telling me that r is not found. How do you call the method since it is in a class? (I am assuming that the error is because of this)
package pack
class Sud(val grid: List[List[Int]]) {
def r(r: Int): List[Int] =
//code
}
object Sud
{
def main(args: Array[String])
{
val puzzle=new Sudoku(List(
List(0, 0, 9, 0, 0, 7, 5, 0, 0),
//rest of Sudoku puzzle created by repeating the above statement
println(r(0)) //ERROR given here
}
}
Upvotes: 2
Views: 14920
Reputation: 3449
As said in the comments, in your code r
is a class method. Hence you need to Instantiate your Class Sud
in order to call that method.
val inst: Sud = new Sud(puzzle)
println(inst.r(0))
Upvotes: 11