Why can’t I instantiate an empty array of a nested class?

This definitely looks like a bug in the compiler, especially as you’re allowed to instantiate an empty array of a nested class just fine; it simply doesn’t work with the initialiser syntax.

I’ll raise a bug. In the meantime, for anyone experiencing the problem, you can work around it by using assignment syntax with an empty array and a specified class for the variable, rather than constructor syntax:

 var foobar: [Wrapper.InsideClass] = []

Leave a Comment