Does somebody have an idea on why this code doesn't compile with Xcode 6 beta 7? It must be a very stupid mistake, or compiler's bug:
enum State : UInt8 {
case Off = 0
case On = 1
}
extension Array {
subscript (index: State) -> Element {
get {
let i = Int(index.toRaw())
return self[i]
}
set {
let i = Int(index.toRaw())
self[i] = newValue
}
}
}
class MyClass {
var results = [0, 7]
func getResult(#state: State) {
return results[state] // Error here: State not convertible to Int ????
}
}
I have tried using a Dictionary [State: Int] instead of Array [Int], and copiler gives also error. Thanks!