- Functional Kotlin
- Mario Arias Rivu Chakraborty
- 73字
- 2021-06-24 19:15:23
The (!!) operator
Instead of a null value, the !! operator will throw an NPE:
val result: String = nullableCupcake!!.eat()
If you can deal with an NPE, the !! operator gives you a pretty convenient feature, a free smart cast:
val result: String = nullableCupcake!!.eat()
val length: Int = nullableCupcake.eat().length
If nullableCupcake!!.eat() doesn't throw an NPE, Kotlin will change its type from Cupcake? to Cupcake from the next line and onwards.
推薦閱讀
- 零起步玩轉掌控板與Mind+
- Oracle從新手到高手
- Leap Motion Development Essentials
- Mastering Entity Framework
- Twilio Best Practices
- 新手學Visual C# 2008程序設計
- Python程序設計
- 精通MATLAB(第3版)
- 移動界面(Web/App)Photoshop UI設計十全大補
- 焊接機器人系統操作、編程與維護
- Machine Learning With Go
- 人人都能開發RPA機器人:UiPath從入門到實戰
- Hands-On Dependency Injection in Go
- JavaScript前端開發基礎教程
- 軟件設計模式(Java版)