// Array contains tuples.(String, Int)
Is it possible to extract only the number 1 index from this array?
let aaa=[("a", 1210),("i", 1215),("u", 1220),("i", 1228),("a", 1230)]
// I want to create an array like this
let bbb=[1210, 1215, 1220, 1228, 1230]
Please
swift2
map
is valid if you want to retrieve the result of applying the same operation to all elements of an array as a new array.
let aaa=[("a", 1210),("i", 1215),("u", 1220),("i", 1228),("a", 1230)]
let bbb=aaa.map {$0.1}//->[1210, 1215, 12220, 1228, 1230]
This feature exists from Swift 1.0 (and earlier beta versions).Unless it's specific to Swift 2.x, many of you may want to tag language questions without version numbers.
© 2024 OneMinuteCode. All rights reserved.