heisenberg
08/13/2021, 1:42 PMfun foo(name: String) {
lastCallMethod = ::foo
}
Now
I want to call the method lastCallMethod
May I ask if there is a way to retrieve the name String that pass using reflection?Zach Klippenstein (he/him) [MOD]
08/13/2021, 1:48 PMname would only be captured if it were actually used inside the lambda, and there’d still be no way to get it out of the lambda object (short of very sketchy reflection tricks). You’d need to create a class to hold both the function reference and the name.heisenberg
08/13/2021, 1:49 PMephemient
08/13/2021, 2:38 PMlastCallMethod? if it's
var lastCallMethod: KFunction<*>? = null
lastCallMethod = ::foo
lastCallMethod?.name
could work, but not if it's () -> Unit or similar (without casting)