I'm trying to extend Array<T> in Swift to add a function that calls self.append. The problem is that Swift won't seem to let me do that - when I try the following code:
extension Array { mutating func AppendObj<T>(obj: T) { //... self.append(obj); } } it says 'T' is not convertable to 'T,' which I assume means that the 'T' the underlying Array is using might be different than the T passed to AppendObj. It also won't allow me to use extension Array<T> ("use of undeclared type T").
Is it possible to extend & use generic structs/methods in Swift? Thanks!
AppendObj. Instead, call itappendObj. Method names should begin with a lower case letter in Swift (and Obj-C).