This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Trait hierarchy -howto

2 replies
edmondo1984
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.
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
H-star Development
Joined: 2010-04-14,
User offline. Last seen 2 years 26 weeks ago.
Re: Trait hierarchy -howto

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

Martin Kneissl 2
Joined: 2011-07-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Trait hierarchy -howto
Define A, B, and C in the same compilation unit (file) and make trait A sealed.
Kind regards,Martin.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland