官术网_书友最值得收藏!

Composing an email

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.

主站蜘蛛池模板: 乌苏市| 兴仁县| 松滋市| 丁青县| 武汉市| 班玛县| 垦利县| 大竹县| 五台县| 修水县| 应用必备| 齐河县| 双桥区| 麦盖提县| 安远县| 平和县| 兴文县| 思茅市| 湟源县| 安岳县| 甘泉县| 阳曲县| 南京市| 宁阳县| 苍南县| 东丰县| 柘城县| 金寨县| 扎赉特旗| 陈巴尔虎旗| 余干县| 西宁市| 志丹县| 钦州市| 乌什县| 新兴县| 鹰潭市| 固原市| 独山县| 夏邑县| 台东市|