ClaudiuB
01/17/2018, 7:06 PMx as? y != null
adam-mcneilly
01/17/2018, 7:08 PMis
can compare against nullable types.
val x: String? = null
println(x is String) // false
println(x is String?) // true
ClaudiuB
01/17/2018, 7:11 PMKClass<Any>
instances, which i can't use in both sides of the is
operatorinfix fun <T : Any> KClass<out Any>.instanceof(clazz: KClass<T>): Boolean {
return try {
this as T
true
} catch (e: ClassCastException) {
false
}
}
Max Russek
01/18/2018, 2:05 AM