Last active
November 17, 2015 16:55
-
-
Save kumo/fcf107ebc78c82cfc7f5 to your computer and use it in GitHub Desktop.
Sketching out my #nanogenwri contribution
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
//: 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