data class House(var name: String = "House", var door: Door = Door())
data class Door(var name: String = "Door")
fun test() {
val testHouse = House("My house", Door(name = "My door"))
}
How could I get nested property reference nice and safe, ideally like this (this doesn't work though):
val houseDoorName = House::door::name
println(houseDoorName.get(testHouse)) //My door
I figured I could maybe do extension function, something like: House::door.nested(Door::name) but Im stuck with the implementation.
testHouse.door.name?MutableMap<String,MutableMap<Int,Any>>. why did you need to use reflection rather thancsv[column][index] = "foo"?val mapping = listOf(House::name toCsvColumn "house name", moremappings...); val listOfHouses = parser.read(House::class, csvFile, mapping)for providing declarative way of doing that. More than anything else, this is just to have fun with Kotlin :)