我似乎有实例使用[foo]()
风格的语法嵌套类类型的空数组问题:为什么我不能实例化一个嵌套类的空数组?
// Playground - noun: a place where people can play
class outsideClass {
}
class Wrapper {
class InsideClass {
}
}
var foo = [outsideClass]() // Works fine
// Invalid use of '()' to call a value of non-function type '[Wrapper.InsideClass.Type]'
var bar = [Wrapper.InsideClass]()
这事我误解,这是我的咖啡前,但我检查了释放笔记,我认为你应该能够引用像这样的嵌套类 - 或测试版7中的错误?
这工作得很好的解决方法:
var foobar: [Wrapper.InsideClass] = []
还有其他''type]()'语法不起作用的情况,例如,与元组。向Apple发送错误报告。 – 2014-09-05 09:13:37
@MartinR谢谢。您的评论和一杯咖啡适合您的信心,我会这样做,并回答这个问题。 – 2014-09-05 10:05:07