Tag: android volley

在Volley的背景下,Kotlin“它”的语法

有人可以向我解释这段代码中的Kotlin'it'语法是如何工作的吗? 这段代码很难阅读,有人把它发给我来解决我的问题,它对于多个连续的请求像魔术一样工作。 我之前使用过Volley,但是这个代码很混乱。 我相信Kotlin比Java更容易阅读,但是这个特殊的代码很难理解。 val responses = mutableListOf<JSONObject>() val myAPIUrl = "https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=" val myAPIKey = "REMOVED" val transportMode = listOf("&mode=driving", "&mode=walking", "&mode=bicycling", "&mode=transit&transit_mode=bus", "mode=transit&transit_mode=subway", "mode=transit&transit_mode=train") val queue = Volley.newRequestQueue(this) transportMode.map { "$myAPIUrl$locationCoordinatesLat,$locationCoordinatesLong&destinations=$locationInput$it&key=$myAPIKey" } .map { JsonObjectRequest(Request.Method.GET, it, null, Response.Listener { responses.add(it) }, Response.ErrorListener { //nothing }) }.forEach { queue.add(it) } }