Last active
March 21, 2018 07:20
-
-
Save ahernandezlopez/ec685f9efcf78d73a33d to your computer and use it in GitHub Desktop.
Useful for SequenceType upcasting, i.e. for upcasting "array of protocol implementers" to array of protocol
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
extension SequenceType { | |
func upcast<T, U where Self.Generator.Element == T>() -> [U] { | |
return flatMap {$0 as? U} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment