- Android Development with Kotlin
- Marcin Moskala Igor Wojda
- 102字
- 2021-07-02 18:48:35
Casts
The casting concept is supported by many programming languages. Basically, casting is a way to convert an object of one particular type into another type. In Java, we need to cast an object explicitly before accessing its member, or cast it and store it in the variable of the casted type. Kotlin simplifies concept of casting and moves it to the next level by introducing smart casts.
In Kotlin, we can perform a few types of cast:
- Cast objects to different types explicitly (safe cast operator)
- Cast objects to different types, or nullable types to non-nullable types, implicitly (smart cast mechanism)
推薦閱讀
- OpenStack Cloud Computing Cookbook(Third Edition)
- C語言程序設(shè)計(jì)習(xí)題解析與上機(jī)指導(dǎo)(第4版)
- Java程序設(shè)計(jì)與計(jì)算思維
- Python高效開發(fā)實(shí)戰(zhàn):Django、Tornado、Flask、Twisted(第2版)
- Mastering Python High Performance
- 數(shù)據(jù)結(jié)構(gòu)(C語言)
- Getting Started with SQL Server 2012 Cube Development
- Learning DHTMLX Suite UI
- C語言程序設(shè)計(jì)
- Mastering Git
- Python 3 數(shù)據(jù)分析與機(jī)器學(xué)習(xí)實(shí)戰(zhàn)
- C語言程序設(shè)計(jì)實(shí)訓(xùn)教程與水平考試指導(dǎo)
- Zabbix Performance Tuning
- Visual FoxPro程序設(shè)計(jì)實(shí)驗(yàn)教程
- Build Your Own PaaS with Docker