Swift Text Output Streams
This code doesn’t look too bad, but it’s a pain to write
var description = ""
andreturn 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 adescription
computed property, all you have to do is write your properties to aTextOutputStream
instance[…]