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

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
主站蜘蛛池模板: 杭锦后旗| 托克逊县| 塔城市| 凤城市| 常德市| 沾化县| 安庆市| 湖州市| 班玛县| 曲阜市| 凤山县| 弥渡县| 杭州市| 来安县| 华池县| 偏关县| 池州市| 登封市| 通榆县| 邢台市| 温州市| 伊金霍洛旗| 卫辉市| 南平市| 新竹市| 阜康市| 钟祥市| 邢台县| 广昌县| 平果县| 玉溪市| 垣曲县| 安图县| 古蔺县| 平顺县| 莒南县| 崇左市| 邻水| 九寨沟县| 嘉义县| 若羌县|