Created
May 2, 2017 00:02
-
-
Save JohannMG/b0c398e0e65aee24f8c40bd9af0e6d52 to your computer and use it in GitHub Desktop.
I write this so much. Saved.
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
import Foundation | |
extension Collection { | |
func onlyType<T>(_ type: T.Type) -> [T] { | |
return self.filter{ $0 is T }.map{ $0 as! T } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment