Skip to content

Instantly share code, notes, and snippets.

@tristandl
Last active January 26, 2019 05:24
Show Gist options
  • Save tristandl/9ca2d5f4ba2e99966b22e24878a2e4fc to your computer and use it in GitHub Desktop.
Save tristandl/9ca2d5f4ba2e99966b22e24878a2e4fc to your computer and use it in GitHub Desktop.
map over object instances, invoking methods on them in Swift
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