Skip to content

Instantly share code, notes, and snippets.

@adamchalmers
Created September 11, 2017 14:43
Show Gist options
  • Save adamchalmers/13546ff168d805c06f46d078830906a6 to your computer and use it in GitHub Desktop.
Save adamchalmers/13546ff168d805c06f46d078830906a6 to your computer and use it in GitHub Desktop.
func extend<T: Collection, U: Collection>(_ base: T, withNewElems: U) -> [T.Iterator.Element]
where T.Iterator.Element == U.Iterator.Element {
let newElems = withNewElems.filter { !base.contains($0) }
return Array(base) + newElems
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment