Last active
July 27, 2022 06:47
-
-
Save algal/0a9aa5a4115d86d5cc1de7ea6d06bd91 to your computer and use it in GitHub Desktop.
print to stderr in Swift 3
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
// known-good: Xcode 8, Swift 3 | |
import Foundation | |
var standardError = FileHandle.standardError | |
extension FileHandle : TextOutputStream { | |
public func write(_ string: String) { | |
guard let data = string.data(using: .utf8) else { return } | |
self.write(data) | |
} | |
} | |
print("I am printed to stderr",to:&standardError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment