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

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)
主站蜘蛛池模板: 三明市| 永德县| 阳朔县| 三穗县| 新宁县| 芜湖市| 清徐县| 深水埗区| 大姚县| 隆昌县| 安丘市| 厦门市| 肇州县| 阜城县| 新田县| 昭苏县| 莲花县| 比如县| 赫章县| 元氏县| 舞阳县| 霍城县| 清涧县| 阿拉善盟| 镇康县| 江孜县| 台东市| 新民市| 延庆县| 丰宁| 申扎县| 阜康市| 略阳县| 德清县| 青浦区| 崇明县| 新竹市| 理塘县| 汨罗市| 舞钢市| 仙游县|