projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
🎨 Rename “newest first” post comparator
[Sone.git]
/
src
/
main
/
kotlin
/
net
/
pterodactylus
/
sone
/
utils
/
Objects.kt
diff --git
a/src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
b/src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
index
6d1d413
..
d9ec162
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
@@
-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()
+ }
+}