tschuchort
09/11/2018, 7:14 PMAndreas Sinz
09/11/2018, 7:15 PMShawn
09/11/2018, 7:16 PMShawn
09/11/2018, 7:17 PMinline fun <reified T> emptyGenericArray(): Array<T> {
return arrayOf()
}bloder
09/11/2018, 7:17 PMinline fun <reified T> genericArrayOf() : Array<T> = arrayOf()bloder
09/11/2018, 7:17 PMtschuchort
09/11/2018, 7:20 PMfun <A : Something> foo(bar: Class<A>): Array<A>Allan Wang
09/11/2018, 7:48 PMkristofdho
09/11/2018, 7:50 PMarrayOfNulls<T>(0) call, T is again not reifiedtschuchort
09/11/2018, 7:53 PMtschuchort
09/11/2018, 7:53 PMkristofdho
09/11/2018, 7:54 PMtschuchort
09/11/2018, 7:57 PMfun <T> Array<T>.plus(element: T): Array<T> though and if I return an arrayOfNulls<Any?>(0) as Array<T> than calling that method on it will failkristofdho
09/11/2018, 8:00 PMplus function already contains the type in this (being an Array<T>), if you're confused as to why it's not reifiedtschuchort
09/11/2018, 8:09 PMArray<T> for any Ttschuchort
09/11/2018, 8:14 PMarrayOfNulls<Any?>(0) as Array<SomeClass?> already doesn't work 😕kristofdho
09/11/2018, 8:22 PMbloder
09/11/2018, 8:30 PMfun <T : Any> genericListOf() : List<T> = arrayOf<KClass<T>>().mapNotNull { it.objectInstance }
Do you know any solution like that to arrays?kristofdho
09/11/2018, 8:58 PMoverride fun <T : Something> foo(bar: Class<T>): Array<T>
= java.lang.reflect.Array.newInstance(bar, 0) as Array<T>diesieben07
09/11/2018, 9:06 PMjava.lang.reflect.Array.newInstance is the way to go if you need this. It's ugly but perfectly fine to use.tschuchort
09/12/2018, 9:07 PMdiesieben07
09/13/2018, 7:16 AM