October 03rd   2014

FizzBuzz in Swift

  Swift

A fizz buzz implementation in Swift using tuples.

A fizz buzz implementation in Swift using tuples.

var aNumber = 15

switch (aNumber % 3, aNumber % 5 ) {
case (0, 0):
    println("fizzbuzz")
case (0, _):
    println("fizz")
case (_, 0):
    println("buzz")
default:
    println(aNumber)
}

«         »

Web Analytics