Nested enum as dictionary key
1 answer
You can fix this using the traditional way of creating a dictionary:
var dict : [OuterStruct.InnerEnum: String] = Dictionary<OuterStruct.InnerEnum, String>()
Note that you can use type inference and not specify the type of the variable:
var dict = Dictionary<OuterStruct.InnerEnum, String>()
As for why the shorthand syntax doesn't work, I don't have an answer - I think you should file a radar about it. I tried to convert InnerEnum
to struct and class and the same error is reported.
+4
source to share