Scala error: ';' expected but "import" found

When I add this class to the scala worksheet, I get an error message:

';' expected, but "import" found.

object polynomials { class Poly(val terms: Map[Int , Double]) { def + (other: Poly) = new Poly(terms ++ other.terms) } val p1 = new Poly(Map(1 -> 2.0, 3 -> 4.0, 5 -> 6.2)) } 

The class looks good to me, is there something missing?

+4
source share
1 answer

It was a mistake. A new version of Worksheet was released a few days ago that fixes it, so go to Help> Check for Updates and the new version should be available for installation. I tried my code on Worksheet 0.1.2.v-2_09-201210230838-85b738a and that is fine.

+9
source

Source: https://habr.com/ru/post/1442494/


All Articles