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

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.

主站蜘蛛池模板: 资阳市| 灵川县| 吴川市| 灵山县| 呼图壁县| 涟源市| 福泉市| 共和县| 绥江县| 阿拉善盟| 乌兰察布市| 雷波县| 塔城市| 霸州市| 千阳县| 马山县| 黄梅县| 达拉特旗| 疏勒县| 秭归县| 峡江县| 武夷山市| 航空| 北流市| 汪清县| 科技| 宜君县| 鄱阳县| 班玛县| 普兰县| 泰来县| 旬邑县| 信丰县| 福贡县| 科尔| 宝山区| 田阳县| 和田市| 锡林郭勒盟| 纳雍县| 文成县|