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

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.

主站蜘蛛池模板: 永济市| 安达市| 响水县| 衡山县| 冀州市| 遂平县| 西充县| 资兴市| 东安县| 庄浪县| 运城市| 延寿县| 枣阳市| 海阳市| 牙克石市| 石棉县| 博客| 井陉县| 新干县| 永福县| 乡宁县| 云霄县| 九江县| 土默特右旗| 平定县| 清河县| 赤城县| 中卫市| 独山县| 伊春市| 孟村| 明光市| 迭部县| 鄂伦春自治旗| 论坛| 南陵县| 开阳县| 罗江县| 乌什县| 襄垣县| 五常市|