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

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
主站蜘蛛池模板: 扶风县| 文水县| 唐山市| 乌鲁木齐市| 桂阳县| 彭州市| 唐海县| 长垣县| 清水县| 安庆市| 临朐县| 盐亭县| 长乐市| 西充县| 越西县| 北碚区| 来宾市| 石棉县| 大英县| 莒南县| 宣恩县| 芜湖县| 虞城县| 泗洪县| 竹北市| 福泉市| 宾阳县| 科技| 定日县| 荆州市| 阿拉善盟| 兴和县| 边坝县| 松溪县| 额敏县| 贞丰县| 徐州市| 旺苍县| 石景山区| 丰都县| 房产|