Skip to content

Instantly share code, notes, and snippets.

@stansidel
Created August 24, 2016 08:05
Show Gist options
  • Save stansidel/b106c49c4410b57bd75ec85845390382 to your computer and use it in GitHub Desktop.
Save stansidel/b106c49c4410b57bd75ec85845390382 to your computer and use it in GitHub Desktop.
Reading input and writing to stderr in Swift (for programming challenges)
import Foundation
public struct StderrOutputStream: OutputStreamType {
public mutating func write(string: String) { fputs(string, stderr) }
}
public var errStream = StderrOutputStream()
let T = Int(readLine()!)!
debugPrint("T = \(T)", toStream: &errStream)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment