toArray (original) (raw)
Brian Goetz brian.goetz at oracle.com
Sun Dec 16 07:01:09 PST 2012
- Previous message: toArray
- Next message: toArray
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This works if you're willing to throw static type safety out the window; we have no compile-time guarantee that U[] is compatible with elements of type T.
On 12/16/2012 5:30 AM, Remi Forax wrote:
On 12/16/2012 01:08 AM, Brian Goetz wrote:
Seems that the minimally invasive version of toArray (that doesn't propagate the horrible convention established by Collection, and yet doesn't foist Object[] on users) is:
interface Stream { Object[] toArray(); T[] toArray(Class clazz); } It is unfortunate to need the Object[] version at all. However, code that is generic in T might be passed a Stream and not know what class literal to use. It is further unfortunate that we cannot say
S[] toArray(Classas then such code could say toArray(Object.class), but we cannot (this is a limitation of generics.) why not ? interface Stream { U[] toArray(Class clazz); } Rémiclazz)
- Previous message: toArray
- Next message: toArray
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-experts mailing list