Number-guessing game in Kotlin I am a Java developer, and I recently gave Kotlin a try.
To begin, I did a little exercise I often do when I start a new language, to verify I got the very basics: the more or less game.
The code I submit there is working fine, but of course I suspect it may be too much like Java, and I would like you to point to me how I can make my code more Kotlin.

package fr.caro

import java.util.*

fun main(args: Array&lt;String&gt;) {
    val min = 0
    val max = 100
    var nbAttempts = 0
    val random = SplittableRandom()
    val reader = Scanner(System.`in`)
    val goal = random.nextInt(min, max)
    var userGuess: Int

    computerSays("I chose a number between $min and $max")
    do {
        nbAttempts++
        computerSays("What's your guess?")
        userGuess = reader.nextInt()
        if (userGuess &gt; goal) computerSays("less !")
        else if (userGuess &lt; goal) computerSays("more !")
    } while(userGuess != goal)

    computerSays("Congratulation ! You found in $nbAttempts attemps.")
}

fun computerSays(text: String) {
    println("Computer : " + text)
}


PS: I wonder if putting the min and max values in a Pair object would be a good idea?
When statement

You could replace:

if (userGuess &gt; goal) computerSays("less !")
else if (userGuess &lt; goal) computerSays("more !")


and

computerSays("Congratulation ! You found in $nbAttempts attemps.")


with:

when {
    userGuess &gt; goal -&gt; computerSays("less !")
    userGuess &lt; goal -&gt; computerSays("more !")
    userGuess == goal -&gt; computerSays("Congratulation ! You found in $nbAttempts attemps.")
}


Extension functions

You could write computerSays as:

fun String.outputAsComputer() {
    println("Computer : " + this)
}


then to output Computer: ABC you could just write:

"ABC".outputAsComputer()


Although there are good arguments for and against this, it is more a chance to get used to extension functions