可选参数值

类 / 方法

class Communication {
    companion object {
        fun sayGoodbye(message: String = "Goodbye!") {
            println(message)
        }

        fun sayHello(message: String = "Hello!") {
            println(message)
        }
    }
}

Communication.sayGoodbye()
//输出 "Goodby!"

Communication.sayHello("Hi")
//输出 "Hi"