简体   繁体   中英

Error with using lambdas, Kotlin

I'm trying to replace method call with lambda expression in Kotlin, but something is wrong and idk what is it.

Here is me code:

httpClient.addInterceptor(interceptor: (Interceptor.Chain?) -> Response {

})

Here is working code without lambdas:

httpClient.addInterceptor(object : Interceptor {
        override fun intercept(chain: Interceptor.Chain?): Response {
}

Use this code:

httpClient.addInterceptor { chain: Interceptor.Chain? ->
  // return a `Response` here
  TODO()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM