I am working to make this code works for optional array, but Xcode complain about:
Cannot assign value of type '[Wrapped.Element]' to type 'Wrapped'
Not sure why should be an error?
extension Optional where Wrapped: RangeReplaceableCollection, Wrapped.Element: Equatable {
mutating func customAppend(_ value: Wrapped.Element) {
if (self != nil) {
self?.append(value)
}
else {
self = [value] // Cannot assign value of type '[Wrapped.Element]' to type 'Wrapped'
}
}
}
Wrapped.Element's constraint toEquatablethere is pointless.