Created
August 23, 2020 05:52
-
-
Save charlieInDen/d68292c003beee094694722263d01833 to your computer and use it in GitHub Desktop.
OwnMap Method
This file contains 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 { | |
// T is the output type | |
func myMap<T>(_ transform: (Element) -> T) -> [T] { | |
var result: [T] = [] | |
self.forEach { (item) in | |
result.append(transform(item)) | |
} | |
return result | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment