Number-guessing game in Kotlin
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