Last active
April 16, 2016 01:17
-
-
Save JoeFerrucci/e1db059e9704841ff3cdd7d07e700a64 to your computer and use it in GitHub Desktop.
Repeat a String a number of times.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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