Last active
August 29, 2015 14:05
-
-
Save siracusa/44ffbdef181fc470e761 to your computer and use it in GitHub Desktop.
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
extension Int { | |
func bottlesOfBeer() { | |
let bottles = "\(self) bottle" + (self == 1 ? "" : "s") | |
let what = " of beer on the wall" | |
println("\(bottles + what), \(bottles) of beer.") | |
print("Take one down, pass it around, ") | |
if self == 1 { | |
println("no more bottles\(what).") | |
} | |
else if self > 0 { | |
let next = self - 1 | |
println("\(next) bottle" + (next == 1 ? "" : "s") + what + ".\n") | |
next.bottlesOfBeer() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment