1
什么
我试过到目前为止回调与单一的参数,它的工作原理:回调与多个参数构造器
class SomeClass (something:Int = 3, val callback: (Int) -> Unit) {
fun doSomething() {
callback(11)
}
}
class AnotherClass {
val something = SomeClass({onSomething(it)})
protected fun onSomething(num: Int) {
// ...
}
}
但如何与多个参数来实现它,如:
class SomeClass (something:Int = 3, val callback: (Int, String) -> Unit) {
fun doSomething() {
callback(11, "Yeah")
}
}
class AnotherClass {
val something = SomeClass(/* ...... what goes here???? */)
protected fun onSomething(num: Int, str: String) {
// ...
}
}