{"id":26404,"date":"2019-08-28T17:01:31","date_gmt":"2019-08-28T21:01:31","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=26404"},"modified":"2019-08-28T17:01:31","modified_gmt":"2019-08-28T21:01:31","slug":"identifiable-in-swift-5-1","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/08\/28\/identifiable-in-swift-5-1\/","title":{"rendered":"Identifiable in Swift 5.1"},"content":{"rendered":"<p><a href=\"https:\/\/nshipster.com\/identifiable\/\">Mattt Thompson<\/a>:<\/p>\n<blockquote cite=\"https:\/\/nshipster.com\/identifiable\/\"><p>The Swift Evolution proposal for <code>Identifiable<\/code>, <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0261-identifiable.md\">SE-0261<\/a>, was kept small and focused in order to be incorporated quickly. So, if you were to ask, <em>&ldquo;What do you actually get by conforming to <code>Identifiable<\/code>?&rdquo;<\/em>, the answer right now is <em>&ldquo;Not much.&rdquo;<\/em> As mentioned in the <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0261-identifiable.md#future-directions\">future directions<\/a>, conformance to <code>Identifiable<\/code> has the potential to unlock simpler and\/or more optimized versions of other functionality, such as the new <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/master\/proposals\/0240-ordered-collection-diffing.md\">ordered collection diffing<\/a> APIs.<\/p><p>[&#8230;]<\/p><p>Normalization is the key to successfully using strings as identifiers. The easiest place to do this is in the initializer, but, again, if you find yourself repeating this code over and over, <a href=\"https:\/\/nshipster.com\/propertywrapper\/\">property wrappers<\/a> can help you here, too. [&#8230;] Unfortunately, the Foundation framework doesn&rsquo;t provide a single, suitable API for URL canonicalization, but <code>URL<\/code> and <code>URLComponents<\/code> provide enough on their own to let you roll your own[&#8230;]<\/p><p>[&#8230;]<\/p><p>As we&rsquo;ve said <a href=\"https:\/\/nshipster.com\/numericcast\/\">time<\/a> and <a href=\"https:\/\/nshipster.com\/never\/\">again<\/a>, often it&rsquo;s the smallest additions to the language and standard library that have the biggest impact on how we write code. (This speaks to the thoughtful, <a href=\"https:\/\/developer.apple.com\/videos\/play\/wwdc2015\/408\/\">protocol-oriented<\/a> design of Swift&rsquo;s standard library.)<\/p><p>Because what <code>Identifiable<\/code> does is kind of amazing: it extends reference semantics to value types.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Mattt Thompson: The Swift Evolution proposal for Identifiable, SE-0261, was kept small and focused in order to be incorporated quickly. So, if you were to ask, &ldquo;What do you actually get by conforming to Identifiable?&rdquo;, the answer right now is &ldquo;Not much.&rdquo; As mentioned in the future directions, conformance to Identifiable has the potential to [&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":"2019-08-28T21:01:37Z","apple_news_api_id":"8c30cb32-3b54-49aa-a3a8-f9e943050dc8","apple_news_api_modified_at":"2019-08-28T21:01:38Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AjDDLMjtUSaqjqPnpQwUNyA","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":[46,71,901,258,489],"class_list":["post-26404","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-programming","tag-swift-programming-language","tag-unicode","tag-url"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26404","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=26404"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26404\/revisions"}],"predecessor-version":[{"id":26405,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26404\/revisions\/26405"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=26404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=26404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=26404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}