rrader
12/02/2018, 1:14 PMobject Users {
val id: Long = 10
val name : String ="name"
val cityId : Long = 42
}
fun main(args: Array<String>) {
slice(Users::name)
}
fun slice(vararg properties: KProperty<Users>) {
properties.forEach { println(it.name) }
}
what should be properties
type that will accept only Users properties?twisterrob
12/02/2018, 4:52 PMKProperty1<Users, *>
should do the trick, but only if class Users
twisterrob
12/02/2018, 4:52 PMval x = Users::name
and turn on type hints, you'll see that for object
it's KProperty0<String>
twisterrob
12/02/2018, 4:59 PMval x : KProperty1<Users, *> = Users::class.declaredMemberProperties.first { it.name == "name" } // val x = Users::name -ish