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

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.

主站蜘蛛池模板: 兰坪| 舟山市| 印江| 同江市| 乌海市| 襄城县| 汕头市| 巴东县| 灌南县| 凤山市| 武定县| 高邮市| 上杭县| 安新县| 固始县| 乌拉特中旗| 黄陵县| 崇州市| 丹东市| 佛冈县| 枞阳县| 光山县| 青神县| 泾阳县| 板桥市| 海宁市| 鄂州市| 华亭县| 合作市| 吉安县| 邵阳县| 萝北县| 武宁县| 湖南省| 都昌县| 历史| 沁水县| 扎鲁特旗| 杭州市| 香河县| 四子王旗|