Skip to main content
2 of 2
added 79 characters in body

OK, I'll give my answer. One problem I had trying this approach is that there are too many combinations: there are cases when you want to use also cases when you want to use let etc. It looks like having the operators and the extension functions independently defined gives you the advantage of a kind of strategy pattern when you can combine different strategies to have an exponential number of configuration without having to define an exponential number of functions.

So you have

Operators:

 1. `?.`
 2. `?:`

Extension functions

a) `also`
b) `let`
c) `run`
d) etc

then you can combine operator 1. with extension fun b) or operator 2. with extension fun c) etc

If you try to define extension funs with null checks then you need to define one function for each combination: it's even difficult just to find names for the functions

So I will keep the otherwise helper fun but I will not use if ifNotNull