Collections2.transform versus Iterators.transform

75 views
Skip to first unread message

Neal Gafter

unread,
Jan 4, 2010, 7:27:48 PM1/4/10
to Google Collections Library - users list, ne...@gafter.com
I notice that Collections2.transform takes a

Function<? super F,T>

but Iterators.transform and Iterables.transform take a

Function<? super F,? extends T>.

Why the difference?

Kevin Bourrillion

unread,
Jan 4, 2010, 7:50:52 PM1/4/10
to Neal Gafter, Google Collections Library - users list, ne...@gafter.com
Oh brother. :-(

As you might remember from a few years ago, we heavily debated between
the two schools of thought on wildcards (and type parameters) like
these -- ones that are not strictly necessary to allow a user with
legitimate inputs to call the method, but rather only serve to
"massage" the resulting type in ways that should in theory not be
needed. Neither approach was clearly superior, but we eventually
settled on leaving them out. However, it looks like we missed
Itera*s.transform() when striving to clean everything up and make it
consistent. We also missed a few of the methods in Predicates, but we
missed them on purpose because the amount of effort to fix existing
user code to use their wildcards correctly was prohibitive.

So now these wildcards are baked in forever -- oh well, no big deal I
guess. There will be worse unfixable offenses we'll discover in the
weeks to come. :-)

> --
> Google Collections Library - users list
> http://groups.google.com/group/google-collections-dev?hl=en
>
> To unsubscribe, send email to:
> google-collections...@googlegroups.com
>

--
Kevin Bourrillion @ Google
internal: http://go/javalibraries
external: guava-libraries.googlecode.com

Reply all
Reply to author
Forward
0 new messages