Skip to content

Instantly share code, notes, and snippets.

@d-date
Created May 1, 2017 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d-date/c8387770b0bdef6499753bee9f81469b to your computer and use it in GitHub Desktop.
Save d-date/c8387770b0bdef6499753bee9f81469b to your computer and use it in GitHub Desktop.
ここでInteger使うと言う発想は話ながら完全に振ってきたやつでした。普段こんなの思いつかない笑 #CodePiece #minna_de_swift
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