CommunicationRequestService

CommunicationRequestService

在下面,我正在尝试Lateinit一个变量,如图所示。但是,在网上浏览了一些示例后,我理解了它的概念,但是由于以下原因,我收到了以下发布的错误消息:
方法setupCommRequestService()中所述的代码

错误信息:

assignment are not expressions kotlin and only expression are allowed

请查看下面发布的代码,并让我知道如何解决它

代码
lateinit var initCommRequestService : Single<CommunicationRequestService>

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    setupCommRequestService()
        .map {
            it.getAllPhotos()
        }

}

fun setupCommRequestService() : Single<CommunicationRequestService> {
    return initCommRequestService = CommunicationRequestService.initRetrofit(this@MainActivity)!!
}
}

最佳答案

fun setupCommRequestService(): Single<CommunicationRequestService> {
  initCommRequestService = CommunicationRequestService.initRetrofit(this@MainActivity)!!
  return initCommRequestService
}

08-04 07:00