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

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.

主站蜘蛛池模板: 凌海市| 林周县| 墨竹工卡县| 三原县| 贵州省| 兴宁市| 阿城市| 闻喜县| 十堰市| 平定县| 浪卡子县| 博罗县| 彩票| 民权县| 汤原县| 西乡县| 武山县| 慈利县| 姜堰市| 蒲城县| 乌兰浩特市| 阳原县| 池州市| 屏东市| 当雄县| 贡觉县| 北安市| 巴东县| 乌鲁木齐县| 高阳县| 宜宾市| 弋阳县| 新巴尔虎右旗| 慈利县| 富平县| 道真| 嘉兴市| 固镇县| 天津市| 柳州市| 兴安盟|