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

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)
主站蜘蛛池模板: 灵武市| 辉县市| 抚远县| 大埔县| 石狮市| 南召县| 柞水县| 扶沟县| 大城县| 龙胜| 丹江口市| 邯郸县| 瓮安县| 收藏| 即墨市| 陇川县| 积石山| 鄂托克前旗| 通州市| 梓潼县| 祁连县| 隆尧县| 忻城县| 正安县| 朝阳区| 财经| 元江| 汉源县| 会理县| 秦安县| 甘泉县| 攀枝花市| 晋江市| 西藏| 无棣县| 宁德市| 崇明县| 扬州市| 嘉禾县| 盖州市| 越西县|