Skip to content

Commit 596860e

Browse files
committed
chore: expand HttpClient explanation in tour extensions
1 parent b2df4f0 commit 596860e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/topics/tour/kotlin-tour-intermediate-extension-functions.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ fun HttpClient.post(url: String): HttpResponse = request("POST", url, emptyMap()
8686
```
8787
{validate="false"}
8888

89-
These `.get()` and `.post()` functions call the `request()` function with the correct HTTP method, so you don't have to.
90-
They streamline your code and make it easier to understand:
89+
These `.get()` and `.post()` functions extend the `HttpClient` class. They can directly use the `request()` function from the `HttpClient` class
90+
because they're called on an instance of the `HttpClient` class as the receiver. You can use these extension functions to
91+
call the `request()` function with the appropriate HTTP method, which simplifies your code and makes it easier to understand:
9192

9293
```kotlin
9394
class HttpClient {
@@ -106,6 +107,7 @@ fun main() {
106107
val getResponseWithMember = client.request("GET", "https://example.com", emptyMap())
107108

108109
// Making a GET request using the get() extension function
110+
// The client instance is the receiver
109111
val getResponseWithExtension = client.get("https://example.com")
110112
}
111113
```

0 commit comments

Comments
 (0)