on Mon Mar 27 2017, Jordan Rose wrote:
>> On Mar 26, 2017, at 01:14, Slava Pestov via swift-users
>> wrote:
>>
>> Hi Ray,
>>
>> There are two overloads of filter() available on ‘array.lazy’; the
>
>> version that takes an escaping closure and returns a
>> LazyFilterCollection, and the versio
> On Mar 26, 2017, at 01:14, Slava Pestov via swift-users
> wrote:
>
> Hi Ray,
>
> There are two overloads of filter() available on ‘array.lazy’; the version
> that takes an escaping closure and returns a LazyFilterCollection, and the
> version that takes a non-escaping closure and returns [
Wow. Thanks for the explanation! I didn’t realize I was toggling between
different overloads but that makes sense now.
Thanks again,
Ray
PS: It is sort of a strange example in the first place (being lazy and then
immediately eager.) I don’t think it is a use case that is compelling enough
to
Here’s another fun one: the following type checks despite the literal closure;
we’ve constrained the return type of filter() to [Int], and not
LazyFilterCollection, so again the type checker picks the overload that
takes the non-escaping closure:
func myFilter(array: [Int], predicate: (Int) ->
Hi Ray,
There are two overloads of filter() available on ‘array.lazy’; the version that
takes an escaping closure and returns a LazyFilterCollection, and the version
that takes a non-escaping closure and returns [Int].
In the first example, we pick the LazyFilterCollection-returning overload,