官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 芜湖县| 临西县| 朔州市| 延安市| 通榆县| 鹿泉市| 平陆县| 保亭| 安图县| 安图县| 水富县| 北碚区| 阜南县| 南丰县| 巴里| 建湖县| 广灵县| 色达县| 黔东| 朝阳县| 壤塘县| 乌审旗| 南溪县| 寿阳县| 中方县| 高台县| 青川县| 碌曲县| 佳木斯市| 渝中区| 鄂伦春自治旗| 吴忠市| 辉南县| 巴林右旗| 娄烦县| 黄大仙区| 扬州市| 台东市| 汉沽区| 陵水| 天气|