Last active
January 26, 2019 05:24
-
-
Save tristandl/9ca2d5f4ba2e99966b22e24878a2e4fc to your computer and use it in GitHub Desktop.
map over object instances, invoking methods on them in Swift
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 Sequence { | |
func map<T>(invoking transform: (Self.Element) throws -> () -> T) rethrows -> [T] { | |
return try map { try transform($0)() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment