Re: Any way to combine for and if-let?
Re: Any way to combine for and if-let?
- Subject: Re: Any way to combine for and if-let?
- From: Greg Parker <email@hidden>
- Date: Tue, 07 Jul 2015 17:28:06 -0700
> On Jul 7, 2015, at 4:58 PM, Rick Mann <email@hidden> wrote:
>
>> On Jul 7, 2015, at 16:52 , Quincey Morris <email@hidden> wrote:
>>
>>> On Jul 7, 2015, at 16:42 , Rick Mann <email@hidden> wrote:
>>>
>>> for item in enumerator!
>>
>> Like this:
>>
>>> for case let item? in enumerator!
>>
>> (Yes, it’s stupid.)
>
> Hmm. It doesn't seem to like that: '?' pattern cannot match values of type 'Element'. It puts the carat on the '?' of item.
>
> Also, the enumerator is a NSDirectoryEnumerator. It returns AnyObject type, so wouldn't there have to be an NSURL cast in there somewhere?
`for case` uses Swift's pattern matching system, as seen in `switch`. Something like this should work:
for case let item as NSURL in enumerator! {
…
}
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden