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

Casts

The casting concept is supported by many programming languages. Basically, casting is a way to convert an object of one particular type into another type. In Java, we need to cast an object explicitly before accessing its member, or cast it and store it in the variable of the casted type. Kotlin simplifies concept of casting and moves it to the next level by introducing smart casts.

In Kotlin, we can perform a few types of cast:

  • Cast objects to different types explicitly (safe cast operator)
  • Cast objects to different types, or nullable types to non-nullable types, implicitly (smart cast mechanism)
主站蜘蛛池模板: 张北县| 株洲县| 资兴市| 天祝| 广河县| 平遥县| 临沧市| 刚察县| 县级市| 东乌| 迁安市| 健康| 青海省| 新乡市| 屏山县| 绥棱县| 长岭县| 河北省| 谢通门县| 军事| 潼关县| 板桥市| 昌宁县| 枝江市| 通化县| 通江县| 灵武市| 阜宁县| 筠连县| 历史| 拜泉县| 资阳市| 天峻县| 墨江| 临朐县| 东源县| 黎川县| 凤台县| 桂东县| 海阳市| 昆山市|