Last active
December 31, 2015 16:03
-
-
Save oisdk/2c7ac33bf2188528842a to your computer and use it in GitHub Desktop.
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
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" { | |
break | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment