Skip to content

Instantly share code, notes, and snippets.

@iezer
Last active September 24, 2016 13:09
Show Gist options
  • Save iezer/232cc7449dc6f573201fe9ed7b1f9a43 to your computer and use it in GitHub Desktop.
Save iezer/232cc7449dc6f573201fe9ed7b1f9a43 to your computer and use it in GitHub Desktop.
import Foundation
func getln() -> String {
let stdin = NSFileHandle.fileHandleWithStandardInput()
var input = NSString(data: stdin.availableData, encoding: NSUTF8StringEncoding)
input = input!.stringByTrimmingCharactersInSet(NSCharacterSet.newlineCharacterSet())
return input as! String
}
print("Hello, what's your name?")
let input = getln()
print(input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment