Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var arr = [2, 3, 4, 5]
- func apply(for array: [Int], transform: (Int) -> Int) -> [Int] {
- var result: [Int] = []
- for element in array {
- result.append(transform(element))
- }
- return result
- }
- apply(for: arr) { $0 * 3 } //[6, 9, 12, 15]
Add Comment
Please, Sign In to add comment