Re: for case and if case (Swift 2)
Re: for case and if case (Swift 2)
- Subject: Re: for case and if case (Swift 2)
- From: Quincey Morris <email@hidden>
- Date: Fri, 12 Jun 2015 03:14:41 +0000
On Jun 11, 2015, at 19:48 , Marco S Hyman <email@hidden> wrote:
>
> switch test {
Roland “maliciously” misused capitalization of types. ‘test’ is actually an enum type, not a variable of enum type, so this switch statement isn’t valid either.
The example in the video is this:
> for case .MyEnumCase (let value) in enumValues {
One thing the video doesn’t show is what ‘enumValues’ is. Perhaps it’s something other than [MyEnum].
What’s odd about ‘for case’ (I think) is that there’s a two-level binding going on. There’s a retrieval of an element of the sequence (of some enum type), then there’s the retrieval of the associated value. Perhaps this is sufficiently complex to implement that it’s not actually done yet.
The following works:
> for case test.two in x {
so the pattern matching itself is implemented. The puzzle is how to correctly bind the associated value.
_______________________________________________
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