projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
🚧 Add detector for mentioned local Sones
[Sone.git]
/
src
/
main
/
kotlin
/
net
/
pterodactylus
/
sone
/
utils
/
Booleans.kt
diff --git
a/src/main/kotlin/net/pterodactylus/sone/utils/Booleans.kt
b/src/main/kotlin/net/pterodactylus/sone/utils/Booleans.kt
index
bfcb319
..
49deb87
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/utils/Booleans.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/utils/Booleans.kt
@@
-9,3
+9,11
@@
fun <R> Boolean.ifTrue(block: () -> R): R? = if (this) block() else null
* Returns the value of [block] if `this` is false, returns `null` otherwise.
*/
fun <R> Boolean.ifFalse(block: () -> R): R? = if (!this) block() else null
* Returns the value of [block] if `this` is false, returns `null` otherwise.
*/
fun <R> Boolean.ifFalse(block: () -> R): R? = if (!this) block() else null
+
+/**
+ * Returns `this` but runs the given block if `this` is `false`.
+ *
+ * @param block The block to run if `this` is `false`
+ * @return `this`
+ */
+fun Boolean.onFalse(block: () -> Unit): Boolean = this.also { if (!this) block() }