java generic boo-hoo

Found another soft spot in Java’s generics

public < C extends java.util.Collection, T > C works( C c, T ... ts ) {
        for ( T t : ts ) c.add( t );
        return c;
}

public < C extends java.util.Collection, T > C broke( C< T > c, T ... ts ) {
        for ( T t : ts ) c.add( t );
        return c;    
}   

Sort of surprised me the latter didn’t work… but the works version was enuff to get ‘er done.

Eh…

Here is the err:

unexpected type
found   : type parameter C 
required: class
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: