Open
Description
Previous ID | SR-9918 |
Radar | rdar://problem/48032239 |
Original Reporter | @sindresorhus |
Type | New Feature |
Additional Detail from JIRA
Votes | 0 |
Component/s | Foundation |
Labels | New Feature |
Assignee | None |
Priority | Medium |
md5: 1fba25807ce87df0c8054a24e5f11a3f
Issue Description:
That would make it easier to work with stdout, stderr, and other file handles. For example, using stderr with `print()` [1].
Currently, every project has to include this extension:
extension FileHandle: TextOutputStream {
public func write(_ string: String) {
write(string.data(using: .utf8)!)
}
}
And then it can be used like this:
var standardError = FileHandle.standardError
print("foo", to: &standardError)
Relevant Stack Overflow question: https://stackoverflow.com/questions/24041554/how-can-i-output-to-stderr-with-swift