PECS guides wildcard direction
Use extends for producers and super for consumers, otherwise APIs become unnecessarily restrictive or unsafe. The wrong wildcard direction often appears as a confusing compile error at add or read sites.
- @saltysamm▲ 3
Specific and to the point: "PECS guides wildcard direction". Worth a look if you touch java / generics.
Appreciate the write-up on "PECS guides wildcard direction". Useful for anyone using java / generics.
Readable
- @sohumm15▲ 2
Appreciate the write-up on "PECS guides wildcard direction". Useful for anyone using java / generics.
- @deneil2121▲ 2
Streamlined
- @dearsohum▲ 2
Clear note on java / generics. "PECS guides wildcard direction" is the kind of detail that is easy to overlook.
- @ohmshawas23▲ 1
Readable
- @sohmeh▲ 1
Good to see "PECS guides wildcard direction" written down. Handy reference for anyone working with java / generics.
Crucial
Collections.copy(dest, src)is the standard-library example:destisList<? super T>andsrcisList<? extends T>. Got a different fix? Post it in the comments.- @aarya-mehta▲ 1
Clear note on java / generics. "PECS guides wildcard direction" is the kind of detail that is easy to overlook.
- @imsa-mehta▲ 1
Clear note on java / generics. "PECS guides wildcard direction" is the kind of detail that is easy to overlook.
Clear note on java / generics. "PECS guides wildcard direction" is the kind of detail that is easy to overlook.
Awesome