0

I get this error on Xcode 8:

Type of expression is ambiguous without more context

When trying to initialize a Dictionary where the key is a String and the value is an enum of a custom struct, here is the line that generates the error:

var myDictionary = [String: MyStruct.MyEnum]()

and here is the class, is contained in the same file of the line above, so I think it's not a problem of scope:

fileprivate struct MyStruct {
    fileprivate enum MyEnum {
        case enumValue1
        case enumValue2
    }
}

Can anyone help me solve this?

Hamish
  • 78,605
  • 19
  • 187
  • 280
allemattio
  • 1,836
  • 17
  • 33
  • 2
    Potentially related? [Why can't I use the short Array constructor syntax when creating an Array of a nested Struct?](http://stackoverflow.com/questions/39041712/why-cant-i-use-the-short-array-constructor-syntax-when-creating-an-array-of-a-n) – JAL Feb 20 '17 at 16:45
  • 1
    I think the issue in the question above is the same, try using a typealias. – JAL Feb 20 '17 at 16:46
  • A typealias solved...thanks!! – allemattio Feb 20 '17 at 16:47

0 Answers0