Request: Need more examples in the docs for learners

As someone who is learning Kotlin, more examples would be a HUGE help.

e.g. I Google what is the “Kotlin-y way” of reading characters from a socket and land on bufferedReader - Kotlin Programming Language

Which is fine - but it isn’t the easy/fun way to make it work. The perfect* example sitting on that page would be:

// Read everything at once
socket.getInputStream().bufferedReader().readText()
// regular BufferedReader if you need to get creative
socket.getInputStream().bufferedReader().use { input -> ... }

and then I would think “Hey, readText looks useful. And I forgot to use use, that is way better!”

* for some value of perfect

2 Likes

We are working now on adding more examples. We haven’t gotten to bufferedReader yet, but we’ll get there.

1 Like

Is crowdsourcing an option?

Yes, you’re welcome to submit examples. Here’s a recently accepted PR adding some examples: Provide samples for Iterables (KT-20357) by tommykw · Pull Request #1366 · JetBrains/kotlin · GitHub