Created
November 18, 2015 01:30
-
-
Save OneSadCookie/6cf90447ed2bed801ae6 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
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