January 2018
Intermediate to advanced
434 pages
14h 1m
English
In the following steps, we will see how to iterate over a class's properties:
class Student constructor(var roll_number:Int, var full_name:String)
fun main(args: Array<String>) { var student=Student(2013001,"Aanand Shekhar Roy") for (property in Student::class.memberProperties) { println("${property.name} = ${property.get(student)}") }}
This is the output:
full_name = Aanand Shekhar Royroll_number = 2013001
Read now
Unlock full access