I am trying to create an array of struct instances like this:
let installers: [AnyObject] = [Homebrew(), Ls()]
But I get this error:
value of type 'Homebrew' does not conform to expected element type 'AnyObject'
When I give the array no type, I get an ambiguous type error and that it needs more context.
Is it possible to accomplish what I am trying to do?
I Googled all over, but I can't find anything.
Any.Anybreaks Swift's type safety and creates many tricky corner cases and subtle bugs (particularly if generics or Optionals are ever involved). It should be avoided except where absolutely necessary. (The same is equally true ofAnyObject.)