How to repeat a string in Swift 4

Next Story

How To Normalize Data In Python With Scikit Learn

Ever wanted to repeat a string x number of times?

There is a simple way to do it in Swift 4.

Check it out:


let numberOfRepeats = 3
String(repeating: "stringToRepeat", count: numberOfRepeats)

So the “stringToRepeat” will repeat numberOfRepeats times.

Leave a Reply

Your email address will not be published. Required fields are marked *

https://www.googletagmanager.com/gtag/js?id=UA-63695651-4