The following works as expected:
indirect enum List {
case Empty
case Value(Int, List)
}
let n = List.Value(123, List.Value(456, List.Empty))
switch n {
case .Empty: print("empty")
case let .Value(v, _): print("value: \(v)")
}
(Printing "value: 123")
But using an "if case" instead of the switch will crash the compiler:
indirect enum List {
case Empty
case Value(Int, List)
}
let n = List.Value(123, List.Value(456, List.Empty))
if case let .Value(v, _) = n {
print(v)
}
(Xcode 7 beta 4, OS X 10.10.4)
Anyone know of a workaround that will let me use if case with indirect enums without crashing the compiler, or do I have to write switches instead until this is fixed?