The issue here I think is with receivers and parameters. The trouble is that currently in Kotlin you can’t just simply compose 2 functions that take lambdas together like that because what do you do for parameters? You’d have to define way to many functions to define those lambdas in a typed fashion.
Like broot said, I think maybe this style should be considered idiomatic for conciseness sake:
You can rename then2 to something more meaningful and provide alternative “thens” for passing results between functions, so e.g. result of doSomething() is passed as a parameter to doSomethingElse(). Still, I don’t consider this a good idea
Omg I actually am that guy and I actually implemented such ‘then’ fun. Even worse, it had three generic parameters because it allowed chaining mapping operations.
And then I had to hand-over the codebase to clueless JAVA devs who asked questions like “what are unit tests” or “how do I switch branch” (company decided to cut costs by hiring twice as many devs which were 7 times cheaper each). The best day in my career XD.