[swift-evolution] Proposal: enum labels for switch cases

Amir Michail a.michail at me.com
Mon Feb 1 17:53:35 CST 2016


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: ...
  }
}


More information about the swift-evolution mailing list