How to repeat a string N times in Swift

1 Answer

0 votes
let s = "swift"

let N = 5
let repeatedstring = String(repeating: s + " ", count: N)

print(repeatedstring)




/*
run:

swift swift swift swift swift 

*/

 



answered Feb 22, 2021 by avibootz
...