This pretty simple code, adding an element to an array of optionals, fails to compile in Fire 8.3.2013 with this error:
Program.swift(11,14): error E486: Parameter 2 is “MyClass?”, should be “MyClass?”, in call to static swift.Array<MyClass?>!.append(_ self: swift.Array<MyClass?>!, _ newElement: MyClass?)
Looking for a workaround to add elements to an array of optionals?
class MyClass
{
}
var array = Array()
let opt:MyClass? = nil
array.append(opt)
works fine in XCode. That was true of NSArray (?), but swift arrays can take pretty much any valid type.
My current horrible work around is to make a java.util.ArrayList<MyClass?>, append the values to that, then force cast it to an Array<MyClass?> , which obviously involves #if COOPER in the middle of otherwise cross platform code.