- Functional Kotlin
- Mario Arias Rivu Chakraborty
- 55字
- 2021-06-24 19:15:23
Checking for non-null types
This is similar to the previous one, but it checks directly for the type:
if (nullableCupcake is Cupcake) {
nullableCupcake.eat()
}
It also works with when:
when (nullableCupcake) {
is Cupcake -> nullableCupcake.eat()
}
Both options, checking for null and non-null types, are a little bit verbose. Let's check other options.
推薦閱讀
- Boost程序庫完全開發(fā)指南:深入C++”準(zhǔn)”標(biāo)準(zhǔn)庫(第5版)
- Android應(yīng)用程序開發(fā)與典型案例
- AngularJS Testing Cookbook
- Delphi程序設(shè)計(jì)基礎(chǔ):教程、實(shí)驗(yàn)、習(xí)題
- PowerCLI Cookbook
- BeagleBone Media Center
- Java 9 Programming Blueprints
- Learning AWS Lumberyard Game Development
- Elastic Stack應(yīng)用寶典
- Node學(xué)習(xí)指南(第2版)
- Python入門很輕松(微課超值版)
- Python計(jì)算機(jī)視覺和自然語言處理
- App Inventor 2 Essentials
- Advanced Python Programming
- 深入理解Kafka:核心設(shè)計(jì)與實(shí)踐原理