mbuhot
02/13/2017, 10:06 PMfun <T, R> T.runIf(condition: Boolean, f: T.() -> R): R? {
return if (condition) { f() } else { null }
}
It behaves a bit like run
from the stdlib, but applies the extension function conditionally, producing a nullable result.