【问题标题】:Error with using lambdas, Kotlin使用 lambdas 时出错,Kotlin
【发布时间】:2018-04-26 07:11:15
【问题描述】:

我正在尝试用 Kotlin 中的 lambda 表达式替换方法调用,但是出了点问题,我想知道是什么。

这是我的代码:

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

})

这是没有 lambdas 的工作代码:

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

【问题讨论】:

标签: android kotlin


【解决方案1】:

使用此代码:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-02
    • 2016-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多