This might be an excessive use of Kotlin, but of the three examples, which would you rather go with?
1️⃣
val channel = payload.obj("channel")?.string("id")
val userId = payload.obj("user")?.string("id")
val text = payload.obj("message")?.string("text")
val responseUrl = payload.getString("response_url")
2️⃣
val (channel, userId, text, responseUrl) = payload.run { listOf(
obj("channel")?.string("id"),
obj("user")?.string("id"),
obj("message")?.string("text"),
getString("response_url")
)}
3️⃣
val (channel, userId, text) = payload.run { Triple(
obj("channel")?.string("id"),
obj("user")?.string("id"),
obj("message")?.string("text")
)}
val responseUrl = payload.getString("response_url")