Nice article. Although I have a question. Why are we passing `this` in `builder(this)`
Melby Baldove
11

I double-checked this just now, and the reason for that is that the builder method passed in is an “extension function of the class OkHttpClient.Builder” (lambda with receiver), so if we want to call it, we need to pass an instance of OkHttpClient.Builder to it.

Because we are already using apply { } on our instance, the this refers to the instance we called apply { } on, so we can pretty much delegate the apply block to the passed in method.

Like what you read? Give Gabor Varadi a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.