© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
D. Pollak et al.Beginning Scala 3https://doi.org/10.1007/978-1-4842-7422-4_7

7. Traits and Enums

David Pollak1  , Vishal Layka2 and Andres Sacco3
(1)
San Francisco, CA, USA
(2)
Bruxelles, Belgium
(3)
Ciudad Autonoma de Buenos Aires, Argentina
 

In this chapter, you will learn two of the most useful features of Scala. These features exist in other languages that use the JVM, like Java or Kotlin—not with the same name but with the same concept behind the scenes.

One of them is traits. Traits function as interfaces in the Java universe and help you construct reusable parts of a program and deal with the tribulations of multiple inheritances, sidestepping the disadvantages ...

Get Beginning Scala 3: A Functional and Object-Oriented Java Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.