Passing multiple arguments to a function depending upon a boolean flag

You could do this, but is questionable whether it is an improvement:

::someFunction.let { if(isEnabled) it(a, b) else it(c, d) }

Alternatively using this instead of it:

::someFunction.run { if(isEnabled) invoke(a, b) else invoke(c, d) }
1 Like