- 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
推薦閱讀
- Apache Hive Essentials
- C語言程序設計實訓教程
- 基于差分進化的優化方法及應用
- Hadoop+Spark大數據分析實戰
- JSP開發案例教程
- Julia高性能科學計算(第2版)
- C語言程序設計上機指導與習題解答(第2版)
- PHP+MySQL+Dreamweaver動態網站開發從入門到精通(第3版)
- Machine Learning in Java
- Orchestrating Docker
- Arduino Wearable Projects
- Instant GLEW
- HTML并不簡單:Web前端開發精進秘籍
- Building E-Commerce Solutions with WooCommerce(Second Edition)
- Mastering MeteorJS Application Development