[swift-evolution] Consolidate Code for Each Case in Enum
Anton Zhilin
antonyzhilin at gmail.com
Thu Jan 12 03:24:20 CST 2017
2017-01-12 0:51 GMT+03:00 David Sweeris <davesweeris at mac.com>:
>
> I don't understand the lines in the struct version where you assign
> something to `self`. What is ".invalid", for example? I thought you'd
> removed the enum altogether.
>
I totally overlooked it. That can't be done with protocols, scrap that
suggestion.
> But pattern matching on structs is impossible—we can change that with a
> separate proposal. For example, we can allow destructuring
> structs/enums/classes by any combination of their properties:
>
> struct S {
> var foo: Int
> var bar: Double
> var buz: String { return "42" }
> }
> let s = S(foo: 42, bar: 42.0)
> let S(foo: x, buz: z) = s
>
> I was under the impression that we could switch over anything that had the
> `~=` operator defined. Is that not the case?
>
Well, this one is a bit different, but it's horribly off-topic for this
thread.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170112/9d74f7ea/attachment.html>
More information about the swift-evolution
mailing list