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

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
主站蜘蛛池模板: 天全县| 康定县| 彭州市| 哈密市| 黎城县| 绍兴县| 循化| 乌鲁木齐市| 开远市| 定远县| 西安市| 阳新县| 垣曲县| 汤原县| 资中县| 惠东县| 乌兰浩特市| 启东市| 洱源县| 萝北县| 安义县| 名山县| 新乡市| 白银市| 南皮县| 香港 | 绥德县| 禹城市| 育儿| 临沂市| 旺苍县| 张家港市| 安阳县| 罗甸县| 灵寿县| 正定县| 鄂温| 天全县| 当阳市| 青神县| 兴山县|