Skip to content

Instantly share code, notes, and snippets.

Last active Dec 31, 2015
What would you like to do?
struct Interact: GeneratorType, SequenceType {
private let prompt: String
init(_ p: String) { prompt = p }
func next() -> String? { print(prompt); return readLine() }
for input in Interact("Say something: ") {
print("You said", input)
if input == "q" {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment