I was seeing the generics part and would like to know why
fun <T> addToList(vararg arg : T): ArrayList<T> {
and
fun addToList(vararg arg : T): ArrayList<T> {
I was seeing the generics part and would like to know why
fun <T> addToList(vararg arg : T): ArrayList<T> {
and
fun addToList(vararg arg : T): ArrayList<T> {
The exact reason would have to ask who created this syntax. My "polite kick" is that it would be more complicated to do the parser in another way. He could consider that the T
that appears in the argument is even a type called T
and not a generic variable of the signature and this would be at least ambiguous. With the initial indication, before any use in the signature, that T
is a generic type, its later use makes it clear that it is the generic slot of type and not a concrete type called T
.