1
我有以下代码:如何使用枚举(在结构中定义)作为字典的关键?
struct TestStruct2 {
let field1: String
let field2: Int
enum TestEnum2 {
case Value1
case Value2
}
}
let dic2 = Dictionary<TestStruct2.TestEnum2, TestStruct2>()
let dic3 = [TestStruct2.TestEnum2 : TestStruct2]()
DIC2成功的作品。
但dic3返回一个编译器错误:
(Type of expression is ambiguous without more context)
我不明白为什么。有任何想法吗?
这是编译器故障,见[为什么不能实例化一个嵌套类的空数组? ](http://stackoverflow.com/questions/25682113/why-cant-i-instantiate-an-empty-array-of-a-nested-class)你也可以使用嵌套类型的'typealias'来工作周围。 – Hamish