Created
May 1, 2017 11:24
-
-
Save d-date/c8387770b0bdef6499753bee9f81469b to your computer and use it in GitHub Desktop.
ここでInteger使うと言う発想は話ながら完全に振ってきたやつでした。普段こんなの思いつかない笑 #CodePiece #minna_de_swift
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
func repeated<T:Integer>(word: String, count: T) -> String { | |
guard count >= 0 else { | |
return "" | |
} | |
return String(repeating: word, count: Int(count.toIntMax())) | |
} | |
repeated(word: "🐬", count: 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment