Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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