Smallville7123
03/26/2019, 6:20 PMRuckus
03/26/2019, 6:26 PMwhos parameters can be redefinedCan you elaborate on that? You can't redefine a function's parameters, unless I'm not understanding what you're asking.
Ruckus
03/26/2019, 6:27 PMSmallville7123
03/26/2019, 6:32 PMUI.kt
inner class callbacks {
fun play() {}
}
fun setup_buttons(Play : android.widgets.button) {
Play!!.setOnClickListener { callbacks().play(Play) }
}
Player.kt
fun play_callback(Play : android.widgets.button) {
if (!UI.variables().mPlayerAdapter!!.isPlaying()) {
UI.variables().mPlayerAdapter!!.play()
Play!!.text = "Pause"
} else {
UI.variables().mPlayerAdapter!!.pause()
Play!!.text = "Play"
}
}
// UI.callbacks.play = play_callback
or somethingSmallville7123
03/26/2019, 6:37 PMfun main(args : Array<String>){
val functions = mutableMapOf<String, () -> Unit>()
functions["first"] = { println("heyo!") }
println(functions)
functions["first"]?.invoke()
}
but im trying to do the same for a paramaterRuckus
03/26/2019, 6:47 PM() -> Unit
is basically just shorthand for "an interface with a method `invoke(): Unit`").
If you want to accept arbitrary arguments, that has to be part of the definition.Smallville7123
03/26/2019, 6:59 PMRuckus
03/26/2019, 7:01 PMdalexander
03/26/2019, 7:02 PMfun <T> doSomething(param: T) { ... }
would accept anything.dalexander
03/26/2019, 7:04 PMSmallville7123
03/26/2019, 7:29 PMfun doSomething(param: <Any>) { ... }
?dalexander
03/26/2019, 7:41 PMT
can do some other stuff. Again it’s hard to provide a helpful suggestion when I don’t really understand what your use case is.