There is an arrayOf
function in kotlin. I want to have the same under different name. I tried:
val each = ::arrayOf<UUID>
val each = ::arrayOf
val each = ::<UUID>arrayOf
val each = arrayOf
I get only compilation errors. is it possible in kotlin? how? or do i have to repeat the whole signature and invocation?
This doesn't work because arrayOf
is an inline function with a reified type parameter. It's not possible to store this reified type parameter as part of a function reference or to pass it when invoking the function through a function reference.
If you want to have an alias for this function, you need to define it differently:
inline fun <reified T> each(vararg x: T) = arrayOf(*x)