``` fun <F: Foo> foo1(fooRef: KProperty1<...
# getting-started
h
Copy code
fun <F: Foo> foo1(fooRef: KProperty1<Bar, Foo>) = ...

fun <F: Foo> foo2(foo: Foo) = foo1(WHAT GOES HERE?)
Is there a simple way to do this?
Bar::(something with foo)
?
k
foo1
takes a property of
Bar
with type
Foo
, and all you've got is an instance or
Foo
. How could that possibly converted to the latter?
h
so let's say
fooRef: KProperty1<Bar, String>
, e.g.
Bar::name
. How could you engineer
KProperty1<Bar, String>
from
name
?
k
Do you happen to be confused about how variables work? If I have a class
class Bar(val name: String)
and then I do
foo2(bar.name)
there's no connection to
bar
anymore,
bar.name
is just an ordinary
String
instance out there with everything else
You can't engineer a property from a random instance, it may not even be a property,
foo("test")
, it may be a "property" of multiple classes, it may be in a list somewhere, ...
h
Yeah, so you can provide the
Bar
part yourself again.
alright. i'll try to think of a different solution
k
I don't get what you want to happen.
👆 2
âž• 1