Skip to content

Instantly share code, notes, and snippets.

@Pallinder
Last active August 29, 2015 14:02
Show Gist options
  • Save Pallinder/aa57c47b374efe1c43e8 to your computer and use it in GitHub Desktop.
Save Pallinder/aa57c47b374efe1c43e8 to your computer and use it in GitHub Desktop.
Sillynames in swift
import Cocoa
extension Array {
func random() -> T {
var r = arc4random_uniform(UInt32(self.count))
return self[Int(r)]
}
}
class SillyName {
let adjectives = ["Black", "White", "Gray", "Brown", "Red", "Pink", "Crimson", "Carnelian", "Orange", "Yellow", "Ivory", "Cream", "Green"]
let nouns = ["head", "crest", "crown", "tooth", "fang", "horn", "frill", "skull", "Bone", "tongue", "throat", "voice", "nose", "snout", "chin", "eye"]
var RandomNoun: String {
return nouns.random()
}
var RandomAdjective: String {
return adjectives.random()
}
func generateStupidName() -> String {
return RandomNoun + RandomAdjective + " " + RandomNoun
}
}
SillyName().generateStupidName()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment