Accessing a function's default parameter value in Kotlin
问题 Can a function's default parameter value be accessed from a function extension, or anywhere else? fun DieRoll.cheatRoll():Int = roll(min = max -1) fun roll(min: Int = 1, max: Int = 6): Int = (min..max).rand() 回答1: No, this is not possible. The default values are not accessible. They are just contained in a bridge-method in the bytecode: fun test(a: Int = 123) { } fun test2() { test() test(100) } Results in the bytecode: public final test(int arg0) { //(I)V <localVar:index=0 , name=this , desc