Chapter 9. Data Classes
We came across the term data class in Chapter 3, Object Oriented Programming in Kotlin ; however, we didn't go into much detail of what it could bring to the table. This chapter will cover the process of annotating classes, which will allow you to have boilerplate-free code. We will dig deep to see what the compiler does for us behind the scenes when we use a data class. In this chapter, you will learn:
- What destructuring is and how data classes are automatically eligible for destructuring operations
- How you get copy, toString, hashCode, and equals methods implemented for you
- Rules to obey when defining data classes
- Limitations of data classes
Data classes are intended for types that are meant to be data containers and nothing ...
Get Programming Kotlin 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.