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

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)
主站蜘蛛池模板: 绵竹市| 稷山县| 梨树县| 巫溪县| 仁布县| 文成县| 新宁县| 亚东县| 静海县| 额敏县| 永康市| 耒阳市| 宜阳县| 巴南区| 玛曲县| 和田县| 呼图壁县| 葵青区| 扎囊县| 蒙自县| 南汇区| 洞口县| 桦南县| 德惠市| 比如县| 察雅县| 耒阳市| 山阴县| 楚雄市| 确山县| 卢湾区| 潜江市| 二连浩特市| 获嘉县| 吉木乃县| 通山县| 玛沁县| 永城市| 平山县| 屯门区| 仁化县|