{"id":18587,"date":"2017-08-10T16:08:49","date_gmt":"2017-08-10T20:08:49","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=18587"},"modified":"2017-08-10T16:08:49","modified_gmt":"2017-08-10T20:08:49","slug":"mixing-constant-and-literal-strings-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2017\/08\/10\/mixing-constant-and-literal-strings-in-swift\/","title":{"rendered":"Mixing Constant and Literal Strings in Swift"},"content":{"rendered":"<p><a href=\"http:\/\/www.figure.ink\/blog\/2017\/5\/29\/mixing-constant-and-literal-strings\">Joshua Emmons<\/a>:<\/p>\n<blockquote cite=\"http:\/\/www.figure.ink\/blog\/2017\/5\/29\/mixing-constant-and-literal-strings\">\n<p>And now we have an interesting decision to make. Do we want to <em>enforce<\/em> safe, well-known constants and provide an <em>option<\/em> to specify arbitrary strings? Or do we want to <em>allow<\/em> arbitrary strings and provide an <em>option<\/em> to specify safe, well-known constants?<\/p>\n<p>[&#8230;]<\/p>\n<p>Situations come up all the time where we need an &ldquo;escape hatch&rdquo; from our carefully calculated set of pre-defined options.<\/p>\n<p>When that happens, we don't need to throw our hands up in despair and make everything a <code>String<\/code>. Enumerations (combined with <code>CustomStringConvertible<\/code> and maybe even <code>ExpressibleByStringLiteral<\/code>) let us work around the 20% case while not jeopardizing the safety and convenience of the 80% out there.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Joshua Emmons: And now we have an interesting decision to make. Do we want to enforce safe, well-known constants and provide an option to specify arbitrary strings? Or do we want to allow arbitrary strings and provide an option to specify safe, well-known constants? [&#8230;] Situations come up all the time where we need an [&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-18587","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\/18587","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=18587"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18587\/revisions"}],"predecessor-version":[{"id":18588,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/18587\/revisions\/18588"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=18587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=18587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=18587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}