WEB Button DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Kotlin - Destructuring Declarations


Kotlin contains many features of other programming languages

Following is the basic syntax of the destructuring declaration.
val (name, age) = person
In the above syntax, we have created an object and defined all of them together in a single statement
println(name)
println(age)
Now, let us see how we can use the same in our real-life application.
fun main(args: Array) {
   val s = Student("Welookups.com","Kotlin")
   val (name,subject) = s
   println("You are learning "+subject+" from "+name)
}
data class Student( val a :String,val b: String ){
   var name:String = a
   var subject:String = b
}
You are learning Kotlin from Welookups.com