On Dec 6, 2013, at 12:18 PM, Hudson, Rick wrote:

> Allen> 1)  For the map method, the source and destination collection are the 
> same object so the collection argument to the closure parameter identifiers 
> both the source and destination object
> 
> Not sure I'm following you here. The collection passed to the closure 
> parameter (aka callback function) in map is the source and not the 
> destination. As far as I can tell the destination isn't available until map 
> returns it.

Right, sorry first post of the morning.  Coffee wasn't active yet.

There is still a difference.  With map, the source collection is the this value 
of the map method and has implementation level visibility of the source 
collection.  The map method is specified to do explicit index iteration over 
the indices of the source collection.   With the from method, the source may 
simply be an Iterable Iterator (an Iterator with a @@iterator method). The 
ultimate source of the data isn't necessarily known to the from method and 
since index-based iteration isn't used to access the iterator, any index passed 
to the closure would be a destination index.  But, as you point out, the 
destination object isn't available to the closure. 

Allen




_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to