-3

var names:[[String]] = [["google"],["yahoo"],["facebook"]]

var convertNames:[String] = []

//how to convert names multi String array to convertNames String Array

1 Answers1

0

Simply use flatMap(_:) on names array to get the required result, i.e.

let names = [["google"],["yahoo"],["facebook"]]

let convertNames = names.flatMap{ $0 }
print(convertNames) //["google", "yahoo", "facebook"]

For detailed info in flatMap(_:) refer link - https://developer.apple.com/documentation/swift/sequence/2905332-flatmap

PGDev
  • 23,751
  • 6
  • 34
  • 88