-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Otto Schnurr edited this page Sep 2, 2014
·
19 revisions
Pump lines of text into Swift scripts.
Declaration
typealias LineOfText = String
Discussion
A collection of characters typically ending with a newline. The last line of a file might not contain a newline.
The FileInput class is a Sequence of LineOfText objects.
Parses input from the command line.
Declaration
func input() -> FileInput
Discussion
Returns a FileInput sequence that iterates over lines of all file paths listed in command line arguments. If that list is empty then standard input is used.
let lineCount = countElements( input() )
println( "\(lineCount) lines" )
A file path of "-" is replaced with standard input.
Constructs a sequence that iterates lines of standard input.
Declaration
init()
Discussion
Creating FileInput using this constructor:
var standardInput = FileInput()
is equivalent to using a "-" file path:
var equivalentInput = FileInput( filePath: "-" )