Tuesday, June 13, 2017

Swift Text Output Streams

Tim Vermeulen:

This code doesn’t look too bad, but it’s a pain to write var description = "" and return description over and over, if this is a pattern you commonly use. It’s also quite easy to forget to add \n to each line.

The relatively unknown standard library protocol TextOutputStreamable solves both of these problems for you. Rather than adding a description computed property, all you have to do is write your properties to a TextOutputStream instance[…]

Comments RSS · Twitter

Leave a Comment