mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 14:47:15 +00:00
add ifTrue/ifFalse
This commit is contained in:
parent
53b89f3a18
commit
da692ccfc3
@ -0,0 +1,17 @@
|
||||
package dev.inmo.micro_utils.common
|
||||
|
||||
inline fun <T> Boolean.ifTrue(block: () -> T): T? {
|
||||
return if (this) {
|
||||
block()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> Boolean.ifFalse(block: () -> T): T? {
|
||||
return if (this) {
|
||||
null
|
||||
} else {
|
||||
block()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user