toArray (was: Migrating methods in Collections)
brian.goetz at oracle.com
Wed Dec 23 21:47:22 UTC 2015
Doug pointed out something to me today that hadn't occurred to me --
that callers of Collection<int>.toArray() might actually *want* an
Object, not an int. Does anyone have opinions on usages that would
inform this one way or the other?
Now that we have streams, we can easily get both:
Collection<int> c = ...
c.stream().toArray() // int
c.stream().boxed().toArray() // Object
c.stream().boxed().toArray(Integer::new) // Integer
So it would even be possible (though a little weird) to completely punt
on migrating toArray() and tell users to go through streams if they want
More information about the valhalla-spec-experts