Reputation: 4231
I have two traits
trait Person
trait Food
why this is compiling :
val pf = new Person with Food //OK
and this is not
val p = new Person //result error: trait Person is abstract; cannot be instantiated
Upvotes: 5
Views: 57
Reputation: 26486
Traits are abstract (not instantiable) by definition. Even if they're fully implemented they may not be instantiated. As senia states in a comment, you can get an anonymous class from a fully implemented trait like this:
trait T1
val t1 = new T1 {}
Upvotes: 1