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

Data classes

It happens quite often that we need to define classes for the sole purpose of holding data. If you have been coding in Scala, I'm sure case classes will come to your mind. Kotlin provides a similar concept, but the term is known as data classes. We will talk a bit more about this type of class in detail in a later chapter, but for now you can define such a class as follows:

    data class Customer(val id:Int, val name:String, var  address:String) 

The compiler does a lot for us when we define a data class, but we will leave these details for later.

主站蜘蛛池模板: 芦溪县| 晋州市| 灵川县| 新竹市| 剑阁县| 永登县| 旬阳县| 宁乡县| 烟台市| 桦甸市| 三明市| 锦屏县| 罗田县| 舞钢市| 建湖县| 兴城市| 长顺县| 唐海县| 眉山市| 玉田县| 莱州市| 岗巴县| 闵行区| 原平市| 青海省| 台江县| 承德县| 贵阳市| 讷河市| 彰武县| 武清区| 安西县| 林甸县| 虹口区| 宜都市| 思南县| 桐梓县| 嫩江县| 修水县| 兴宁市| 大足县|