[swift-users] LazyCollection.map()

Dmitri Gribenko gribozavr at gmail.com
Tue Jun 28 18:38:47 CDT 2016


On Tue, Jun 28, 2016 at 3:37 PM, Aaron Bohannon via swift-users
<swift-users at swift.org> wrote:
> Does the code below have a well-defined behavior?

It invokes the eager map() that is available on Array.lazy.
Array.lazy is a collection, so it has an eager map() from the
Collection protocol.  The lazy map() does not accept a throwing
closure, so it does not match and the type checker chooses the eager
one.

Arguably, in non-generic context this code should not type check.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-users mailing list