Request: Need more examples in the docs for learners


#1

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 https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/java.io.-input-stream/buffered-reader.html

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


#3

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


#4

Is crowdsourcing an option?


#5

Yes, you’re welcome to submit examples. Here’s a recently accepted PR adding some examples: https://github.com/JetBrains/kotlin/pull/1366