-3

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

var convertNames:[String] = []

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

0

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.