`.toArray()` for all generators

Andreas Rossberg rossberg at google.com
Thu Aug 29 01:55:57 PDT 2013


On 28 August 2013 17:02, Forbes Lindesay <forbes at lindesay.co.uk> wrote:
> It would be nice from a readability point of view if `iteratable.toArray()`
> could always be used as a substitute for `Array.from(iteratable)`.  Is there
> a way that could be neatly achieved?  It would also be nice if methods like
> `.map` and `.filter` existed on iteratables.  C# does this via the concept
> of extension methods, but I wonder whether something similar could be
> achieved here, at least in the case of built in iteratables?

In addition to what others have already said, note that iterators
model streams that are not necessarily finite. Hence, a toArray method
would not generally be well-defined.

/Andreas


More information about the es-discuss mailing list