3 ms·
> In Java it is used to let the compiler know and it will erase the <T> and make it a concrete type. It's the opposite. In Java, when you instantiate a generic
by scott_s 10y ago
> In Java it is used to let the compiler know and it will erase the <T> and make it a concrete type.
It's the opposite. In Java, when you instantiate a generic class with a concrete type, it will erase that type in the generic class. So, the actual code for Foo<String> and Foo<Integer> is the same; String and Integer are erased, and inside of Foo, it just uses Object. For that reason, Foo<T> is not allowed to do anything with T that would require knowing the actual type of T; that knowledge has been erased. See https://docs.oracle.com/javase/tutorial/java/generics/erasure.html https://docs.oracle.com/javase/tutorial/java/generics/erasur...
With this confusion, it's hard for me to orient myself with how this applies to Swift.