enum X {
case L1: L1Type
case L2: L2Type
enum L1Type {
case A, B, C
}
enum L2Type {
case D, E, F
}
}
···
On 2 February 2016 at 10:53, Amir Michail via swift-evolution < swift-evolution@swift.org> wrote:
These labels allow you to group items in an enum:
enum X {
L1:
case A, B
case C
L2:
case D, E, F
}
switch x {
case L1: handleL1(x)
case L2: handleL2(x)
}
func handleL1(x:X) {
switch x L1 {
case .A: ...
case .B: ...
case .D: ...
}
}
func handleL2(x:X) {
switch x L2 {
case .D: ...
case .E: ...
case .F: ...
}
}
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution
It’s not nested. You can still put all the cases in one switch and ignore the labels if you want to.
···
On Feb 1, 2016, at 7:03 PM, Howard Lovatt <howard.lovatt@gmail.com> wrote:
enum X {
case L1: L1Type
case L2: L2Type
enum L1Type {
case A, B, C
}
enum L2Type {
case D, E, F
}
}
On 2 February 2016 at 10:53, Amir Michail via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
These labels allow you to group items in an enum:
enum X {
L1:
case A, B
case C
L2:
case D, E, F
}
switch x {
case L1: handleL1(x)
case L2: handleL2(x)
}
func handleL1(x:X) {
switch x L1 {
case .A: ...
case .B: ...
case .D: ...
}
}
func handleL2(x:X) {
switch x L2 {
case .D: ...
case .E: ...
case .F: ...
}
}
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org> https://lists.swift.org/mailman/listinfo/swift-evolution
On 2 February 2016 at 11:03, Howard Lovatt <howard.lovatt@gmail.com> wrote:
Isn't that just a nested enum:
enum X {
case L1: L1Type
case L2: L2Type
enum L1Type {
case A, B, C
}
enum L2Type {
case D, E, F
}
}
On 2 February 2016 at 10:53, Amir Michail via swift-evolution < > swift-evolution@swift.org> wrote:
These labels allow you to group items in an enum:
enum X {
L1:
case A, B
case C
L2:
case D, E, F
}
switch x {
case L1: handleL1(x)
case L2: handleL2(x)
}
func handleL1(x:X) {
switch x L1 {
case .A: ...
case .B: ...
case .D: ...
}
}
func handleL2(x:X) {
switch x L2 {
case .D: ...
case .E: ...
case .F: ...
}
}
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution