Last active
August 29, 2015 14:02
-
-
Save Pallinder/aa57c47b374efe1c43e8 to your computer and use it in GitHub Desktop.
Sillynames in swift
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
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