- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Trait hierarchy -howto
Fri, 2012-01-13, 09:24
Dear all,I would need to implement a trait hierarchy, with three Traits:
Trait A
Trait B extends A
Trait C extends A
and I would not like any concrete or abstract class to extends directly Trait A.
Is it possible to do that in Scala?
Best Regards
Edmondo
Trait A
Trait B extends A
Trait C extends A
and I would not like any concrete or abstract class to extends directly Trait A.
Is it possible to do that in Scala?
Best Regards
Edmondo
Fri, 2012-01-13, 09:51
#2
Re: Trait hierarchy -howto
Define A, B, and C in the same compilation unit (file) and make trait A sealed.
Kind regards,Martin.
Kind regards,Martin.
put all in one file and put a "sealed" keyword in front of the A trait
http://stackoverflow.com/questions/3032771/scalas-sealed-abstract
-------- Original-Nachricht --------
> Datum: Fri, 13 Jan 2012 09:24:57 +0100
> Von: Edmondo Porcu
> An: scala-user
> Betreff: [scala-user] Trait hierarchy -howto
> Dear all,
> I would need to implement a trait hierarchy, with three Traits:
>
> Trait A
>
> Trait B extends A
>
> Trait C extends A
>
> and I would not like any concrete or abstract class to extends directly
> Trait A.
>
> Is it possible to do that in Scala?
>
> Best Regards
>
> Edmondo