robstoll
06/17/2019, 1:40 PMcomponentN() => https://kotlinlang.org/docs/reference/multi-declarations.htmlBob Glamm
06/17/2019, 1:44 PMcomponentN is defined differently based on type and each componentN shares no common ancestor. That only leaves reflection as a possible solution...robstoll
06/17/2019, 1:46 PMkralli
06/17/2019, 1:46 PMinterface Component<T> {
operator fun component1(): T
}robstoll
06/17/2019, 1:47 PMdiesieben07
06/17/2019, 1:48 PMrobstoll
06/17/2019, 1:49 PMcomponentNrobstoll
06/17/2019, 1:50 PMdata class but I doubt that there is something and hoped for componentNdiesieben07
06/17/2019, 1:50 PMrobstoll
06/17/2019, 1:52 PMdiesieben07
06/17/2019, 1:52 PMcomponentN has no meaning on it's own. What does this component do? Why exactly component1? Why not 2? It only makes sense attached to a specific type.diesieben07
06/17/2019, 1:53 PMrobstoll
06/17/2019, 1:53 PMcomponentN implemented, without any interface involved and this makes senserobstoll
06/17/2019, 1:54 PMdiesieben07
06/17/2019, 1:54 PMcomponentN functions?robstoll
06/17/2019, 1:56 PMfun <T: WithComponent1<R>, R> foo(t: T): R = t.component1()diesieben07
06/17/2019, 1:57 PMcomponent1 does in this case. It could produce a username, the amount of items in a data structure, an average, whatever.robstoll
06/17/2019, 1:59 PMdiesieben07
06/17/2019, 1:59 PMrobstoll
06/17/2019, 2:02 PMdiesieben07
06/17/2019, 2:03 PMkralli
06/17/2019, 2:04 PMcomponenN method, but without using an interface? I don't know any mechanisms in Kotlin that support that.gildor
06/17/2019, 2:10 PMgildor
06/17/2019, 2:11 PM