As a software architect, one of my main channels of communication is email. Probably this is true of most software development roles.
An email has the following:
An address (at least one is mandatory)
CC (zero or more, optional)
Title (optional)
Body (optional)
Attachment (zero or more, optional)
Let's assume I'm really lazy, and would like to schedule emails to be sent while I'm actually biking around the neighborhood.
The actual scheduling logic will be postponed to Chapter 8, Threads and Coroutines, and Chapter 9, Designed for Concurrency, which discuss scheduling and concurrency. For now, let's see what our Mail class may look like:
data class Mail(val to: String, val cc: List<String>, val bcc: List<String>, val title: String?, val message: String)
So, we've already seen data class in action in the previous chapters. We've also discussed nullable and non-nullable types, such as String? versus String.
Now is a good time to discuss how collections work in Kotlin, since this is the first time we have a class that deals with them directly.