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

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
主站蜘蛛池模板: 广昌县| 秭归县| 鱼台县| 陕西省| 绥化市| 启东市| 遂川县| 甘南县| 资溪县| 霍州市| 焉耆| 江都市| 漳州市| 宝清县| 陇川县| 东至县| 沙湾县| 广宁县| 兴安盟| 定西市| 南澳县| 孙吴县| 沽源县| 珠海市| 肥东县| 拉孜县| 白城市| 北流市| 澜沧| 台江县| 克什克腾旗| 鄂尔多斯市| 比如县| 昔阳县| 嘉兴市| 雷波县| 安吉县| 汉川市| 湟中县| 博乐市| 东乌珠穆沁旗|