2 ms·
> If your data have a complicated type like List<Set<Pair<Foo, ? extends Bar>>>, you have to copy-paste this type everywhere, without a way to name it succinctl
by Izkata 7y ago
> If your data have a complicated type like List<Set<Pair<Foo, ? extends Bar>>>, you have to copy-paste this type everywhere, without a way to name it succinctly.
Java has had generic type inference since at least 7 [0], so all you need is <>
It's not perfect, but I believe it's been improved with each version.
[0] https://docs.oracle.com/javase/7/docs/technotes/guides/language/type-inference-generic-instance-creation.html https://docs.oracle.com/javase/7/docs/technotes/guides/langu...
- nine_k 7y agoYes, this is what I called "diamond operator". I'm talking about a different use case where inference via assignment does not work, e.g. a method declaration: public List<Set<Pair<Foo, ? extends Bar>>> combine( List<Set<Pair<Foo, ? extends Bar>>> a, List<Set<Pair<Foo, ? extends Bar>>> b ) {...} It would be great to have something like type Quux = List<Set<Pair<Foo, ? extends Bar>>>; public Quux combine(Quux a, Quux b) {...} Unfortunately, I'm not aware of any plans to introduce that.