Can I have kotlin extension function that do something like this:
// extension
inline fun <T : Any> T?.runIfNotNull(function: (T) -> Unit) {
this?.let { function(it) }
}
// some function
fun doSomething(int: Int){
// do something
}
// doSomething will be called with maybeNullInt as argument,
// when maybeNullInt is not null
maybeNullInt?.runIfNotNull { doSomething }
basically, what I want is replace
maybeNullInt?.let{ doSomething(it) }
with
maybeNullInt?.runIfNotNull { doSomething }