locke
12/10/2018, 5:19 PMShawn
12/10/2018, 5:20 PMlocke
12/10/2018, 5:22 PMfun <Class>.<function>(<arguments>)
yields a request for a type argument from the compiler and, <Class>.Companion.<function>(<arguments>)
yields an unresolved reference.Shawn
12/10/2018, 5:23 PMfun JavaClass.function(args) { }
should work just fine - where do the type arguments come into play?fun <T> T.function(args) { }
locke
12/10/2018, 5:25 PMJavaClass
is genericized, and so the compiler requests a type argument, i.e. it's scoping that function to only JavaClass<T>
.
I am trying to get it to work with just JavaClass.function...
without needing to give it a type argument.Shawn
12/10/2018, 5:25 PMfun JavaClass<*>.function()
locke
12/10/2018, 5:28 PMObservable
in RxJava. It's using both fromIterable
and interval
that are static on Observable
. I guess since they're static I can just use Observable.fromIterable
instead of this.fromIterable
but that certainly feels like a code smellShawn
12/10/2018, 5:29 PMlocke
12/10/2018, 5:30 PMthis
should refer to the Companion
in this context and thus those methods should be available in scope without needing to define it. I.e. just calling fromIterable
which is implicitly this.fromIterable
Observable.function
doesn't expose this extension.Shawn
12/10/2018, 5:32 PMlocke
12/10/2018, 5:34 PMObservable.function
doesn't actually reference the Observable<*>.function
declaration. I'm sure if I had an instance of Observable
I would have access, but that's not the goal.Shawn
12/10/2018, 5:35 PMkarelpeeters
12/10/2018, 5:36 PMShawn
12/10/2018, 5:36 PMlocke
12/10/2018, 5:36 PMObservable.myFunction(<arguments>)
Shawn
12/10/2018, 5:37 PMlocke
12/10/2018, 5:37 PMShawn
12/10/2018, 5:38 PMkarelpeeters
12/10/2018, 5:38 PMlocke
12/10/2018, 5:39 PMgildor
12/11/2018, 12:38 AM