Last active
June 19, 2018 08:55
-
-
Save valexa/618d9a594188bb83ca75cfc3c47b6d76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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