All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kamelia.sprinkler.util.Typing.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
package com.kamelia.sprinkler.util

/**
 * Casts this nullable object to the specified type [T].
 *
 * @receiver the object to cast or null
 * @return the object cast as [T]
 */
@Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE")
inline fun  Any?.unsafeCast(): T = this as T

/**
 * Tries to cast this nullable object to the specified type [T].
 * If the cast fails, returns null.
 *
 * @receiver the object to cast or null
 * @return the object cast as [T] or null if the cast fails
 */
inline fun  Any?.castOrNull(): T? = this as? T




© 2015 - 2024 Weber Informatics LLC | Privacy Policy