Questions tagged [universal-trait]
2 questions
6
votes
1 answer
Value classes, universal traits and the necessity of instantiation
In the specification of value classes, it says:
A value class can only extend universal traits and cannot be extended itself. A universal trait is a trait that extends Any, only has defs as members, and does no initialization. Universal traits…

oxbow_lakes
- 133,303
- 56
- 317
- 449
1
vote
0 answers
Purpose of Scala trait extending AnyVal?
Sometimes in Scala/Scala.js I see trait Foo extends AnyVal { ... } – what's the meaning and purpose of extends AnyVal here?
I'm aware of value classes, and that they can not extend traits that extend AnyRef, so using extends AnyVal would make sense…

Nikita
- 2,924
- 1
- 19
- 25