https://kotlinlang.org logo
d

dmitry.petrov

06/06/2016, 9:26 AM
... or, as someone proposed a while ago,
Copy code
object A {
    operator fun <T> get(vararg x: T): Array<out T> = x
}

val test1: MutableList<Int> = A[1, 2, 3].toMutableList()
val test2: Set<String> = A["1", "2", "3"].toSet()
This would not work for annotations, though.