Retrieve default parameter value via reflection


#1

Given this example:

data class Example(val abc: Int = 100)

How would I be able to tell the default value of abc is 100 via reflection? Assume I have the KParameter instance already.


#2

The default value is not actually a property of the parameter. If you use default values the compiler will generate overloaded methods and constructors. The default value is part of the body of these methods and constructors.