In Kotlin data classes, they can be degraded as follows:
fun main(args: Array<String>) {
val thing = Stuff(1, "Hi", true)
val(thing1, thing2, thing3) = thing
println(thing1)
}
data class Stuff(val thing1: Int, val thing2: String, val thing3: Boolean)
I might have read documents incorrectly, or maybe I just couldn’t find an example, but I'm looking for a way to implement custom destructuring classes without data. Is this possible in Kotlin?
source
share