-4

I have user array and I want concat values with ','

for s in userArray {

}

I want the result be A,B,C,D

How could I do this in Swift 3?

1
  • 1
    Why use a loop? Use the joined function. Commented Feb 20, 2017 at 17:04

1 Answer 1

2

Use the array joined(separator:) function

let joined = stringArray.joined(separator: ", ")
Sign up to request clarification or add additional context in comments.

2 Comments

what if it's not a stringArray? it's userList I want concat user emails
let joined = userArray.map { $0.email }.joined(separator: ",")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.