Repeat a string X times

 Problem

I want to repeat a string several times.



 Recipe


// String literal
var s : String

// Set 's' to 5 x "Hello"

for var i in 0..<5 {
    s += "Hello"
}
print(s)

				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground