書名: 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.
推薦閱讀
- 零基礎玩轉區塊鏈
- 深度強化學習算法與實踐:基于PyTorch的實現
- Web程序設計(第二版)
- C語言從入門到精通
- 計算機應用基礎案例教程
- Hands-On Neural Network Programming with C#
- Advanced UFT 12 for Test Engineers Cookbook
- Programming Microsoft Dynamics? NAV 2015
- Oracle 12c從入門到精通(視頻教學超值版)
- Java EE項目應用開發
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- Java程序設計教程
- Android應用開發攻略
- Developer,Advocate!
- Raspberry Pi Robotic Projects