Skip to content

Instantly share code, notes, and snippets.

@JoeFerrucci
Last active April 16, 2016 01:17
Show Gist options
  • Save JoeFerrucci/e1db059e9704841ff3cdd7d07e700a64 to your computer and use it in GitHub Desktop.
Save JoeFerrucci/e1db059e9704841ff3cdd7d07e700a64 to your computer and use it in GitHub Desktop.
Repeat a String a number of times.
extension String {
func times(count: Int, separatedBy separator: String = "") -> String {
return Array(count: count, repeatedValue: self).joinWithSeparator(separator)
}
static func times(count: Int, repeatedValue s: String, separatedBy separator: String = "") -> String {
return Array(count: count, repeatedValue: s).joinWithSeparator(separator)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment