Skip to content

Instantly share code, notes, and snippets.

@suraphanL
Last active September 10, 2016 19:14
Show Gist options
  • Save suraphanL/83f565fc089897ae3ee21b9c2df7a4c4 to your computer and use it in GitHub Desktop.
Save suraphanL/83f565fc089897ae3ee21b9c2df7a4c4 to your computer and use it in GitHub Desktop.
let intArray = [0, 1, 2, 3, 4]
let mappedStrings = intArray.map { (number) -> String in
return "\(number)"
}
// ^ Result: ["0", "1", "2", "3", "4"]
let squared = intArray.map { (number) -> Int in
return number * number
}
// ^ Result: [0, 1, 4, 9, 16]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment