Collections2.transform versus Iterators.transform

Skip to first unread message

Neal Gafter

Jan 4, 2010, 7:27:48 PM1/4/10
to Google Collections Library - users list,
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

Jan 4, 2010, 7:50:52 PM1/4/10
to Neal Gafter, Google Collections Library - users list,
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
> To unsubscribe, send email to:

Kevin Bourrillion @ Google
internal: http://go/javalibraries

Reply all
Reply to author
0 new messages