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) {
// ...
}
}