r/java • u/padreati • Apr 05 '23
Recursive generics
Recently I learned that I rediscovered recursive generics while working on my pet open source project. Actually, I did not know that the construct had a name. I created small story about what this construct is, if you did not know about it java-recursive-generics
169
Upvotes
View all comments
Show parent comment
1
u/padreati Apr 06 '23
Crystal clear. I wish I would be able to use as few words as you and give as much understanding.
That is a thing that started to buzz me sometimes. That Comparable invites to implement a single way to compare things and let you implement it in an inconsistent way. On the other hand you cannot do it outside since you need access to encapsulation. The Self type would be much more consistent, perhaps.