So glad you've written this article. I encountered similar issue, except the compiler just don't let it pass.
In my case I was trying to make a custom `Single` after `Completable`. So I wrote
```
val someData = 3L
Completable.complete()
.andThen<Long> {
val someJudge: Boolean = someData > 0L
return@andThen if (someJudge) Single.error<Long>(Exception())
else Single.just<Long>(someData)
}.subscribe {
println("The number is $it")
}
```
but compiler says `andThen` has "Overload resolution ambiguity."
It was that moment, I realized that I could NOT pass `Single` back such way in an `andThen` lambda expression.
After using your `Single.defer` lambda solution, it works like a charm:
```
Completable.complete()
.andThen(Single.defer {
val someJudge: Boolean = someData < 0L
if (someJudge) Single.error<Long>(Exception())
else Single.just(someData)
}).blockingSubscribe {
println("The number is $it")
}
```