Guest User

Untitled

a guest
Nov 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. func genericApply<T>(to array: [Int], transform: (Int) -> T) -> [T] {
  2. var result: [T] = []
  3. for element in array {
  4. result.append(transform(element))
  5. }
  6. return result
  7. }
  8.  
  9. genericApply(to: arr) { String($0) } //["2", "3", "4", "5"]
Add Comment
Please, Sign In to add comment