Skip to content

Instantly share code, notes, and snippets.

@siracusa
Last active August 29, 2015 14:05
Show Gist options
  • Save siracusa/44ffbdef181fc470e761 to your computer and use it in GitHub Desktop.
Save siracusa/44ffbdef181fc470e761 to your computer and use it in GitHub Desktop.
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