♻️ Replace UpdateChecker with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / utils / Objects.kt
index 6d1d413..d9ec162 100644 (file)
@@ -5,3 +5,9 @@ val Any?.unit get() = Unit
 
 fun <T> T?.throwOnNullIf(throwCondition: Boolean, exception: () -> Throwable) =
                if (this == null && throwCondition) throw exception() else this
+
+fun <T> T?.onNull(block: () -> Unit) = this.also {
+       if (this == null) {
+               block()
+       }
+}