5

When I add this class to a scala worksheet I receive the error :

';' 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 fine to me, is there something missing ?

5
  • 2
    you might want to show the code that contains the import...
    – Kim Stebel
    Oct 27, 2012 at 15:33
  • 2
    @Kim Stebel im not importing anything, i think this might be a scala worksheet bug
    – user701254
    Oct 27, 2012 at 15:38
  • So the worksheet is otherwise empty?
    – Kim Stebel
    Oct 27, 2012 at 15:39
  • Then I'd say it's a bug.
    – Kim Stebel
    Oct 27, 2012 at 15:45
  • 1
    duplicate: stackoverflow.com/questions/12615964/…
    – Arjan
    Oct 27, 2012 at 15:46

1 Answer 1

9

This was a bug. A new version of the 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 your code on Worksheet 0.1.2.v-2_09-201210230838-85b738a and it's fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.