{"id":18159,"date":"2017-06-13T16:28:45","date_gmt":"2017-06-13T20:28:45","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=18159"},"modified":"2017-06-13T16:28:45","modified_gmt":"2017-06-13T20:28:45","slug":"swift-text-output-streams","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/06\/13\/swift-text-output-streams\/","title":{"rendered":"Swift Text Output Streams"},"content":{"rendered":"<p><a href=\"http:\/\/ericasadun.com\/2017\/06\/11\/working-with-text-output-streams\/\">Tim Vermeulen<\/a>:<\/p>\n<blockquote cite=\"http:\/\/ericasadun.com\/2017\/06\/11\/working-with-text-output-streams\/\">\n<p>This code doesn&rsquo;t look too bad, but it&rsquo;s a pain to write <code>var description = \"\"<\/code> and <code>return description<\/code> over and over, if this is a pattern you commonly use. It&rsquo;s also quite easy to forget to add <code>\\n<\/code> to each line.<\/p>\n<p>The relatively unknown standard library protocol <code>TextOutputStreamable<\/code> solves both of these problems for you. Rather than adding a <code>description<\/code> computed property, all you have to do is write your properties to a <code>TextOutputStream<\/code> instance[&#8230;]<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Tim Vermeulen: This code doesn&rsquo;t look too bad, but it&rsquo;s a pain to write var description = \"\" and return description over and over, if this is a pattern you commonly use. It&rsquo;s also quite easy to forget to add \\n to each line. The relatively unknown standard library protocol TextOutputStreamable solves both of these [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[71,901],"class_list":["post-18159","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=18159"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18159\/revisions"}],"predecessor-version":[{"id":18160,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18159\/revisions\/18160"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=18159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=18159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=18159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}