John
11/03/2019, 5:26 PMwithIf(myObject.propertyToFiler == true) { myObject -> ... }
molikuner
11/03/2019, 5:29 PMif (myObject.propertyToFiler == true) with(myObject) { myObject -> ... }
inline fun <T, R : Any> withIf(x: T, access: Boolean, block: (T) -> R) = if (access) with(x, block) else null
streetsofboston
11/03/2019, 5:51 PMtakeIf
and takeUnless
.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/take-if.htmlJohn
11/03/2019, 6:24 PMtakeIf
is that I thought I’d seen before