Skip to content

Instantly share code, notes, and snippets.

@OneSadCookie
Created November 18, 2015 01:30
Show Gist options
  • Save OneSadCookie/6cf90447ed2bed801ae6 to your computer and use it in GitHub Desktop.
Save OneSadCookie/6cf90447ed2bed801ae6 to your computer and use it in GitHub Desktop.
protocol Output {
func isSameAs(o: Output) -> Bool
}
extension Output where Self: Equatable {
func isSameAs(o: Output) -> Bool {
guard let o = o as? Self else { return false }
return self == o
}
}
extension String: Output {
// don't need to do anything; the default implementation picks it up
}
var outputs: [Output] = []
func remove(output: Output) {
for (i, o) in outputs.enumerate() {
if o.isSameAs(output) {
outputs.removeAtIndex(i)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment