1 package net.pterodactylus.sone.utils
4 * Returns the value of [block] if `this` is true, returns `null` otherwise.
6 fun <R> Boolean.ifTrue(block: () -> R): R? = if (this) block() else null
9 * Returns the value of [block] if `this` is false, returns `null` otherwise.
11 fun <R> Boolean.ifFalse(block: () -> R): R? = if (!this) block() else null
14 * Returns `this` but runs the given block if `this` is `false`.
16 * @param block The block to run if `this` is `false`
19 fun Boolean.onFalse(block: () -> Unit): Boolean = this.also { if (!this) block() }