Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala public methods: ';' expected but 'def' found

I wrote this method:

public def getXScaleFactor(panelWidth: Int): Double = {
  return (panelWidth / (samplesContainer[0].length.asInstanceOf[Double]))
}

and I have problems with compilation:

[error] ./src/main/scala/Controllers/TrackController.scala:85: ';' expected but 'def' found.
[error]   public def getXScaleFactor(panelWidth: Int): Double {
[error]          ^

What is wrong in this code?

like image 386
ciembor Avatar asked Jun 03 '11 17:06

ciembor


1 Answers

public is not a reserved word in Scala, so it's interpreting it as a variable name. Public access is the default; just leave off public and you'll be fine.

like image 106
Rex Kerr Avatar answered Sep 28 '22 12:09

Rex Kerr