Kotlin - 型のチェック

公開日:2019-11-06 更新日:2019-11-06
[Kotlin]

1. 概要

型のチェックを行います。


2. 型のチェック

is で型の判定が行えます。
var x:Any = "123"

if (x is String) println("String") // 123
if (x is Int)    println("Int")