Skip to content

Instantly share code, notes, and snippets.

@hotchpotch
Created June 5, 2014 09:47
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 hotchpotch/77d35a795340e05cda0e to your computer and use it in GitHub Desktop.
Save hotchpotch/77d35a795340e05cda0e to your computer and use it in GitHub Desktop.
extension Int {
func fizzbuzz() -> String {
switch (self % 3 == 0, self % 5 == 0) {
case (true, false):
return "Fizz"
case (false, true):
return "Buzz"
case (true, true):
return "FizzBuzz"
default:
return String(self)
}
}
}
for n in 0...100 {
println(n.fizzbuzz())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment