How to repeat a string n times in Swift

1 Answer

0 votes
import Foundation

var s = "abc"
var n = 3

var repeated = String(repeating: s, count: n)

print(repeated)



/*
run:

abcabcabc

*/

 



answered Dec 23, 2024 by avibootz
...