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