June 2018
Intermediate to advanced
310 pages
6h 32m
English
Let's try a fluent setter approach instead. We'll have only mandatory fields in our constructor, and all others will become setters, so the creation of a new email would look something like this:
Mail("manager@company.com").title("Ping").cc(listOf<String>())
That's a lot nicer for many reasons:
Let's see one way of implementing this approach. There are other convenient ways to do it, which we'll discuss in Chapter 10, Idioms and Anti-Patterns:
data class ...Read now
Unlock full access