Merge branch 'release-0.9.7'
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / utils / Booleans.kt
1 package net.pterodactylus.sone.utils
2
3 /**
4  * Returns the value of [block] if `this` is true, returns `null` otherwise.
5  */
6 fun <R> Boolean.ifTrue(block: () -> R): R? = if (this) block() else null
7
8 /**
9  * Returns the value of [block] if `this` is false, returns `null` otherwise.
10  */
11 fun <R> Boolean.ifFalse(block: () -> R): R? = if (!this) block() else null