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
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 {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With