Hi all. How to access the R of kproperty1 <T, R...
# announcements
r
Hi all. How to access the R of kproperty1 <T, R>? For exemple: class Foo (val name: String) val test: String = Foo::name (getting error: "Required String, found KProperty1<Foo, String>)
k
Cal
.get()
on it:
Copy code
class A(val name: String)
val a = A("John")

a::name.get() // => "John"
k
That's for when you have a
KProperty0<String>
like
a::name
, for a
KProperty1<A, String>
like
A::name
you need
get(a)
which takes an instance:
Copy code
val x = A::name
val a = A("test")
x.get(a)
r
thank you.