Skip to content

Instantly share code, notes, and snippets.

@kumo
Last active November 17, 2015 16:55
Show Gist options
  • Save kumo/fcf107ebc78c82cfc7f5 to your computer and use it in GitHub Desktop.
Save kumo/fcf107ebc78c82cfc7f5 to your computer and use it in GitHub Desktop.
Sketching out my #nanogenwri contribution
//: Playground - noun: a place where people can play
import UIKit
enum SentenceEnd: String {
case FullStop = "."
case QuestionMark = "?"
case ExclamationMark = "!"
}
struct Sentence: CustomStringConvertible {
var words: [String] = []
var end: SentenceEnd = .FullStop
var description: String {
get {
return words.joinWithSeparator(" ") + end.rawValue
}
}
init(words: [String]) {
self.words = words
switch arc4random_uniform(100) {
case 0...9:
end = .QuestionMark
case 10...19:
end = .ExclamationMark
default:
end = .FullStop
}
}
}
var sentence = Sentence(words: ["the", "cat", "sat", "on", "a", "mat"])
print(sentence)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment