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?
source share