5 ms·
Since when are generics automatic casting?
by bitmapper 5y ago
Since when are generics automatic casting?
- techsin101 5y agoit's not but it's essentially the same practically speaking -- you get type A|B|C you write code to interact with it in just one way. Either by casting, or generics. weakly typed language do that for you, but they are looked down on.
- myoon 5y agoI think you're missing the key point of statically typed languages, that the compiler catches errors for you. Generics are valuable because it allows users to write "generic" reusable functions that are still checked by the compiler. Of course dynamically-typed languages can do this easily, but that's not the point.