我这里出现了这个错误。
Type inference failed: fun <R : Any!> flatMap(p0: ((Response<ResendOtpResponseDto!>) -> SingleSource<out R!>!)!): Single<R!> cannot be applied to ((Response<ResendOtpResponseDto!>) -> KFunction1<@ParameterName Response<ResendOtpResponseDto>, Single<ResendOtpResponseDto>>)
我不知道为什么
这是我的代码,错误就在这里。
这里是我的parseResendOtpResponse:
flatMap
函数的第一个参数是一个函数引用。this::parseResendOtpResponse
是一个函数引用,所以你必须把它放在括号里。
当你想立即传递函数主体时,我们使用大括号。
list.flatMap({it.items}) // lambda within parentheses
list.flatMap(){it.items} // lambda outside parentheses
list.flatMap {it.items} // lambda without parentheses
val fn: (List<List<...>>) -> List<...> = { it.items } //lambda
list.flatMap(fn)
以上都代表了相同的调用