Skip to content

Instantly share code, notes, and snippets.

@valexa
Last active June 19, 2018 08:55
Show Gist options
  • Save valexa/618d9a594188bb83ca75cfc3c47b6d76 to your computer and use it in GitHub Desktop.
Save valexa/618d9a594188bb83ca75cfc3c47b6d76 to your computer and use it in GitHub Desktop.
//1 , cant be right as assigning instance variable does not make a copy
var fooBar = self.fooBar
fooBar.forEach({ foo in
if foo.id == bar.id {
fooBar.remove(at: fooBar.index(of: foo)!)
}
})
self.fooBar = fooBar
//2, seems right as enumerated makes a copy
for (index, foo) in self.fooBar.enumerated() where foo.id == bar.id {
self.fooBar.remove(at: index)
}
//3 Expression type 'Bool' is ambiguous without more context
public func remove(location: LocationModel) {
self.locationsList.removeAll { $0.id == location.id }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment