3
votes

From the documentation, a universal trait can be used for value class:

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 allow basic inheritance of methods for value classes, but they incur the overhead of allocation.

  • How else universal trait can be used in Scala?
1
it can be used to make somethings of universal type. Ex you have some business models and make them as of universal type bizModelRaman Mishra

1 Answers

3
votes

Use in value classes is the only point of universal traits, and all of their limitations are chosen to allow this single use.