commonMain.dev.inmo.micro_utils.common.IfBoolean.kt Maven / Gradle / Ivy
package dev.inmo.micro_utils.common
inline fun Boolean.letIfTrue(block: () -> T): T? {
return if (this) {
block()
} else {
null
}
}
inline fun Boolean.letIfFalse(block: () -> T): T? {
return if (this) {
null
} else {
block()
}
}
inline fun Boolean.alsoIfTrue(block: () -> Unit): Boolean {
letIfTrue(block)
return this
}
inline fun Boolean.alsoIfFalse(block: () -> Unit): Boolean {
letIfFalse(block)
return this
}
inline fun Boolean.ifTrue(block: () -> T): T? {
return if (this) {
block()
} else {
null
}
}
inline fun Boolean.ifFalse(block: () -> T): T? {
return if (this) {
null
} else {
block()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy