On Feb 9, 9:26 am, [email protected] (Dominic Mitchell) wrote:
> Hear, hear! Although, I'd call it "of" rather than create, as that's
> what the google collections library does. The type inference leads to a
> really nice API.
Thanks, Dominic. I used your message as an incentive to replace our
Pair constructor with an "of" factory method. And yes, it does a great
job of cleaning things up! I hit one snag. Is there a way around the
following compilation problem?
public class PairTest {
/*
* The Pair.of() call below yields the following compilation
error: Type
* mismatch: cannot convert from Pair<Class<capture#1-of ? extends
* Exception>,Class<capture#2-of ? extends Exception>> to
Pair<Class<?
* extends Exception>,Class<? extends Exception>>
*/
public static void main(String[] args) {
Class<? extends Exception> foo;
Class<? extends Exception> bar;
// Original line with constructor.
Pair<Class<? extends Exception>, Class<? extends Exception>>
compiles = new Pair<Class<? extends Exception>, Class<? extends
Exception>>(
foo, bar);
// Failed attempt at using of.
Pair<Class<? extends Exception>, Class<? extends Exception>>
doesntCompile = Pair.of(
foo, bar);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---