Created
August 2, 2014 22:00
-
-
Save albtsantos/6e55d2aebb19200033f4 to your computer and use it in GitHub Desktop.
Multiplicator infix for Swift strings
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
@infix func * (string: String, multiplicator: Int) -> String { | |
if multiplicator < 0 { | |
return "" | |
} | |
var finalString: String = "" | |
for i in 0..<multiplicator { | |
finalString += string | |
} | |
return finalString | |
} | |
"abc" * 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment