1

Possible Duplicate:
scala and traits on object instances

Is it possible to mix in a trait to an already existing object ?

Something like:

val s = new MyClass
val sWithTrait = s with myTrait

The code above does not work, but maybe the syntax is wrong or it is not possible at all ?

Community
  • 1
  • 1
John Threepwood
  • 15,593
  • 27
  • 93
  • 149
  • See this http://stackoverflow.com/questions/3893274/scala-and-traits-on-object-instances ... hope it helps – Kyle Jun 21 '12 at 18:39

1 Answers1

4

Dynamic mixins are not possible in regular Scala, but I seem to remember that there was an attempt at a compiler plugin called Autoproxy that allowed something along these lines. Not sure about the state of it though.

Emil L
  • 20,219
  • 3
  • 44
  • 65