Skip to content

Instantly share code, notes, and snippets.

@audrl1010
Created May 19, 2020 16:50
Show Gist options
  • Save audrl1010/bc60b7512e93c316d84a41732b98e6a1 to your computer and use it in GitHub Desktop.
Save audrl1010/bc60b7512e93c316d84a41732b98e6a1 to your computer and use it in GitHub Desktop.
merge

// MARK: - Merge extension Array where Element: Equatable {

func merge(target: [Element]) -> [Element] {
    let result = target.filter { item -> Bool in
        return self.contains(where: { item == $0}) == false
    }
    return self + result
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment