Why the code print "Hello World"

Hi all, I am learning Kotlin with Samples. With the code following:

fun run() {

    val run: () -> Unit = {
        println("Run run run!")

    // 新增一个 run 函数
    fun run() = println("Hello World")

    object : Runnable {
        override fun run() = run()

fun main(args: Array<String>) {

Why the console print “Hello World” not “Run run run!” . Thanks!


You can see an explanation here:

language design - How resolving Kotlin functions/properties with the same name work? - Stack Overflow.


Thank you very much. I Got it.