Something a bit goofy about Generics  
Author Message
Roedy Green





PostPosted: 2007-10-25 22:27:00 Top

java-programmer, Something a bit goofy about Generics
Iterable<? extends JavaFileObject>

You'd think a JavaFileObject[] or a JavaFileObject... would fullfil
that requirement, but it doesn't. It fills it sufficiently to do a
for:each but not to satisfy this parameter.

That is like a piece of purple lint on a white sweater.

People say arrays and generics don't mix, but they damn well SHOULD.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
The Ghost In The Machine





PostPosted: 2007-10-26 2:12:00 Top

java-programmer >> Something a bit goofy about Generics In comp.lang.java.advocacy, Roedy Green
<email***@***.com>
wrote
on Thu, 25 Oct 2007 14:27:03 GMT
<email***@***.com>:
>
> Iterable<? extends JavaFileObject>
>
> You'd think a JavaFileObject[] or a JavaFileObject... would fullfil
> that requirement, but it doesn't. It fills it sufficiently to do a
> for:each but not to satisfy this parameter.
>
> That is like a piece of purple lint on a white sweater.
>
> People say arrays and generics don't mix, but they damn well SHOULD.

A workaround, of course, is passing in

Arrays.asList(p)

where p is JavaFileObject[].

I agree that it's a blemish, though.

--
#191, email***@***.com
GNU and improved.

--
Posted via a free Usenet account from http://www.teranews.com

 
Daniel Pitts





PostPosted: 2007-12-20 4:19:00 Top

java-programmer >> Something a bit goofy about Generics Roedy Green wrote:
> Iterable<? extends JavaFileObject>
>
> You'd think a JavaFileObject[] or a JavaFileObject... would fullfil
> that requirement, but it doesn't. It fills it sufficiently to do a
> for:each but not to satisfy this parameter.
>
> That is like a piece of purple lint on a white sweater.
>
> People say arrays and generics don't mix, but they damn well SHOULD.
The truth is that the for:each construct takes *either* an array or an
Iterable.

I agree, Generics and Arrays should mix. Although, Arrays are
"primitives", and should not be "obsessed" over.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>