- Android Development with Kotlin
- Marcin Moskala Igor Wojda
- 110字
- 2021-07-02 18:48:35
Smart casts
Smart casting converts a variable of one type to another type, but as opposed to safe casting, it is done implicitly (we don't need to use the as or as? cast operator). Smart casts work only when the Kotlin compiler is absolutely sure that the variable will not be changed after checking. This makes them perfectly safe for multithreaded applications. Generally, smart casts are available for all immutable references (val) and for local mutable references (var). We have two kinds of smart cast:
- Type smart casts cast an object of one type to an object of another type
- Nullity smart casts cast nullable references to non-nullable
推薦閱讀
- OpenStack Cloud Computing Cookbook(Third Edition)
- JavaScript+DHTML語法與范例詳解詞典
- SQL基礎教程(視頻教學版)
- Working with Odoo
- INSTANT Sinatra Starter
- Regression Analysis with Python
- Scratch·愛編程的藝術家
- PyQt編程快速上手
- Java7程序設計入門經典
- JSP程序設計與案例實戰(慕課版)
- Flask Web開發:基于Python的Web應用開發實戰(第2版)
- C#面向對象程序設計(第2版)
- Web開發的平民英雄:PHP+MySQL
- 分布式數據庫HBase案例教程
- Java核心編程