https://kotlinlang.org logo
#getting-started
Title
# getting-started
j

janvladimirmostert

08/08/2022, 10:28 AM
I'm trying to find a way to model
query<Int, String>(sql: String)
so that it will output
O2<Int, String>
since it has two output types or if it's
query<Int, Int, Int>
outputting
O3<Int, Int, Int>
etc or
query<T1,T2,...,T99>(sql: String)
should return
O99<T1,T2,...,T99>
Alternatively,
query(O(Int, String)
should output
O<Int, String>
How would you go about designing such an API? I've tried a few things which I've posted on SO, I've implemented the "alternatively" part, but ran into the problem where I'm outputting
O2<Int.Companion, String.Companion>
instead of
O2<Int, String>
which I could probably solve by doing
query(O(InstanceOfInt, InstanceOfString)
, but that already looks terrible. https://stackoverflow.com/questions/73271850/make-kotlin-function-output-tnk1-kn-when-the-input-is-tnk1-companion-kn-com
4 Views