Comment

Comment by Genmutant

An use case that comes up quite often is building a List / Map / Set implementation. You want to have it to enforce to (typesafe) take only objects of the same type, and when taking it out again, get the object in the same type back. And you want the compiler to complain, when to try to put a String in a List<int> (a list of strings), or try to asign the object you get out of the list to a boolean.

And obviously you don't want to write a specific List implementation for every Type, like a StringList, DoubleList, IntList,... especially as every method in it would basically work the same.

parent Genmutant 4 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton