Create a string with n blank spaces or other repeated character

后端 未结 4 1966
一生所求
一生所求 2020-12-15 05:55

I want to make a string with n blank spaces using Swift, but without using a for loop or manually like this:

// string with 5-blank spa         


        
4条回答
  •  难免孤独
    2020-12-15 06:42

    In Swift 3:

    var s = String(repeating: " ", count: 5)
    

    https://developer.apple.com/reference/swift/string/2427723-init

提交回复
热议问题