Closed exoego closed 5 years ago
I think that the use of Upper/Lower type bounds, even when accurated, can be confused for new-comers.
I need to find an acceptable way to express the behavior of mapConserve
, both in the description and the diagram.
I think that the use of Upper/Lower type bounds, even when accurated, can be confused for new-comers.
Understood.
I need to find an acceptable way to express the behavior of
mapConserve
, both in the description and the diagram.
Awesome !! Closing this in favor of #12.
I think "preserving its parameterized type" is not accurate description, simplification aside.
Above example shows mapConserve can accept
A => B
as long asB
is a super type ofA
. IIUC, a characteristic ofmapConserve
is that it will return the collection instance itself when all mapped elementseq
to original.And,
A
andB
should be a sub type ofAnyRef
, notAny
. So the signature also needs correction. https://www.scala-lang.org/api/2.13.0/scala/collection/immutable/List.html#mapConserve[B%3E:A%3C:AnyRef](f:A=%3EB):List[B] I will simplify this todef mapConserve[B]
if it is too much detail for new readers.