a function which has some parameters with default value. Only during runtime I can know which is default. Are there any way except reflection? Thank you for your help
In theory default parameter in function can be some property (which includes calculated or mutable one) : import kotlin.random.Random fun main() { foo(2) foo() foo() bar(2) bar() altNumber = 5 bar() } val someNumber get() = Random.nextInt() fun foo(number: Int = someNumber) = println(number) var altNumber = 4 fun bar(number: Int = altNumber) = println(number) So you kinda can avoid reflection by assigning current default value somewhere. Maybe there are better solutions for that, but that's the first thing that comes to my mind :)
Thank you for your help. It might be a resolution for that. xD
In fact I can't achieve that, because looks the default value expression or other representation of the default value is not included in the MetaData
Обсуждают сегодня