diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/IfBoolean.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/IfBoolean.kt new file mode 100644 index 00000000000..b953f423eb6 --- /dev/null +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/IfBoolean.kt @@ -0,0 +1,17 @@ +package dev.inmo.micro_utils.common + +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() + } +}