Skip to content

Instantly share code, notes, and snippets.

@zwaldowski
Last active August 29, 2015 14:02
Show Gist options
  • Save zwaldowski/35d79c7bcd4f126e222a to your computer and use it in GitHub Desktop.
Save zwaldowski/35d79c7bcd4f126e222a to your computer and use it in GitHub Desktop.
import Swift
@assignment func -=<T, U where T: ArrayType, U: Sequence, T.GeneratorType.Element: Equatable, T.GeneratorType.Element == U.GeneratorType.Element>(inout lhs: T, rhs: U) {
for removingItem in rhs {
for (index, item) in enumerate(lhs) {
if removingItem == item {
lhs.removeAtIndex(index)
}
}
}
}
var arr1 = [ "one", "two", "three" ]
var arr2 = [ "two", "three" ]
arr1 -= arr2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment