Structure Destructure
Structuring
• It means creating/assembling an object. For example, in Kotlin:
• Here we created a Customer object. In other words, we did some structuring.
val m1 = Musteri(1, "Ali")
Destructuring
• It means breaking an object into pieces. In other words, it's the process of extracting the values stored in "a data class" into individual variables.
val (id, isim) = m1
Destructuring In the background:
val id = m1.component1() // 1
val isim = m1.component2() // "Ali"
val id = m1.component1() // 1
val isim = m1.component2() // "Ali"
• Structuring = To assemble an object, to build (val m1 = Musteri(1, "Ali"))
• Destructuring = Disassemble the object (val (id, isim) = m1)