- Learn Kotlin Programming(Second Edition)
- Stephen Samuel Stefan Bocutiu
- 107字
- 2021-06-24 14:13:32
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.
推薦閱讀
- JBoss Weld CDI for Java Platform
- Mastering Adobe Captivate 2017(Fourth Edition)
- Visual C++實(shí)例精通
- Windows Presentation Foundation Development Cookbook
- Kotlin Standard Library Cookbook
- Mastering macOS Programming
- 精通Python設(shè)計(jì)模式(第2版)
- 學(xué)習(xí)正則表達(dá)式
- Python High Performance Programming
- Python圖形化編程(微課版)
- Scratch·愛(ài)編程的藝術(shù)家
- Python語(yǔ)言科研繪圖與學(xué)術(shù)圖表繪制從入門(mén)到精通
- Vue.js 3應(yīng)用開(kāi)發(fā)與核心源碼解析
- Practical GIS
- 大學(xué)計(jì)算機(jī)基礎(chǔ)實(shí)訓(xùn)教程