What’s the point of lower bounds on generic types? For a while, I took for granted that you may as well have lower bounds if you have upper bounds, but that otherwise they’re mostly for academic symmetry, not something practical. After looking further, this is the best answer I can come up with:

Lower bounds expand the list of ways to create a value of that type (like how upper bounds expand the list of things to do with a value of that type).

Lower bounds are similar to union types in the same way that upper bounds are similar to intersection types. Thus, if a language has union+intersection types, it almost doesn’t need bounds at all.

Lower bounds allow for richer subtyping relationships than union types, while being more verbose in some cases.

Lower bou…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help