Implementation of abstract traits in with clause

71 views Asked by At

Possible Duplicate:
In Scala how can I advise my own methods?

Assume:

trait SomeAbstractTrait {
    val transform : Int => Int
}

Why does the following work:

new SomeClass() with SomeTrait with SomeAbstractTrait {
   val transform : Int => Int = (x) => x*2
}

while

new SomeClass() with SomeAbstractTrait {
   val transform : Int => Int = (x) => x*2
} with SomeTrait 

does not?

Having to declare traits with a single abstract function object before I can use them is a bit annoying and since the first version works I assume I just got the syntax wrong?

0

There are 0 answers