Alan B
12/09/2022, 1:15 PMSam
12/09/2022, 1:30 PMthis@toPublic
would be used to disambiguate if there were multiple possible receivers. It means “the receiver of the toPublic
method”. In your case it’s not necessary because there’s only one receiver in scope. You can just write this
.
2. Your second example doesn’t compile because the compiler doesn’t know what types would be valid for the receiver parameter. You can fix it by making an additional reified type parameter for the input
type, e.g. I
, and then using I::class
in place of input::class
.Sam
12/09/2022, 1:35 PMAny
. And then it has to be reified because input::class
has type KClass<out I>
, whereas I::class
has type KClass<T>
(which is what you need if you want to call member functions on it)Alan B
12/09/2022, 1:57 PMAlan B
12/09/2022, 2:17 PMSam
12/09/2022, 2:31 PMreified I: Any
in where it’s declared, rather than using I & Any
at the use siteAlan B
12/09/2022, 3:14 PMAlan B
12/09/2022, 3:27 PMfun Private.toPublic() = assign<Public>(this)
I’m sure other’s have written such libraries, but, I’m just trying to get a grip around it.Alan B
12/09/2022, 3:27 PM