safeCast

@JvmName(name = "safeCast")
inline fun <T : Any> safeCast(obj: Any?, kClass: KClass<T>): T?

Casts the given obj to T or returns null if the cast fails.

Return

The cast object or null.

Parameters

obj

The object to cast.

kClass

The class to cast to.

T

The type to return.