var myStr = "Swift"
let myCh: Character = "S"
var myArr = Array(repeating: String(myCh), count: myStr.count)
myArr // ["S", "S", "S", "S", "S"]
This code doesn't work in swift 5.5, how can i repeat it in other way?
Solution:
var myStr = "Swift"
let myCh: Character = "S"
var myArr = [String]()
myStr.forEach {_ in
myArr.append("\(myCh)")
}
print(myArr)