Last active
July 4, 2017 08:04
-
-
Save tranhieutt/813f2a7a0b311a8294113b72c28a34b5 to your computer and use it in GitHub Desktop.
[Swift] - map - extension
This file contains hidden or 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
let scores :[NSNumber] = [0,28,124] | |
let words = scores.map {NumberFormatter.localizedString(from: $0, number:.spellOut) } | |
print(words) | |
//Console: ["zero", "twenty-eight", "one hundred twenty-four"] | |
// | |
let milesToPoint = ["Point1":120.0,"Point2":45.0,"Point3":55.0] | |
let kmToPoint = milesToPoint.map{name,miles in miles*1.67} | |
//console: [200.39999999999998, 75.149999999999991, 91.849999999999994] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment