{"id":15857,"date":"2016-09-29T11:35:45","date_gmt":"2016-09-29T15:35:45","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=15857"},"modified":"2016-09-29T11:35:45","modified_gmt":"2016-09-29T15:35:45","slug":"whats-in-a-swift-collection","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/09\/29\/whats-in-a-swift-collection\/","title":{"rendered":"What&rsquo;s in a Swift Collection?"},"content":{"rendered":"<p><a href=\"https:\/\/oleb.net\/blog\/2016\/09\/collection-associated-types\/\">Ole Begemann<\/a>:<\/p>\n<blockquote cite=\"https:\/\/oleb.net\/blog\/2016\/09\/collection-associated-types\/\">\n<p>Collections in Swift are very powerful but also <a href=\"http:\/\/chris.eidhof.nl\/post\/protocols-in-swift\/\">very complex<\/a>. If you want to implement your own custom collection type, you need to understand how the <a href=\"https:\/\/developer.apple.com\/reference\/swift\/collection\"><code>Collection<\/code><\/a> protocol works. And even if all you want to do is <em>use<\/em> the familiar collection types from the standard library, we think it&rsquo;s worth learning how things work, not least because it can be a big help in decoding what the compiler wants to tell you with its error messages.<\/p>\n<p>In this article, we&rsquo;d like to discuss the <code>Collection<\/code> protocol&rsquo;s <a href=\"https:\/\/developer.apple.com\/library\/content\/documentation\/Swift\/Conceptual\/Swift_Programming_Language\/Generics.html#\/\/apple_ref\/doc\/uid\/TP40014097-CH26-ID189\">associated types<\/a>. This might seem like an obscure topic, but we think understanding what the associated types do and why they are needed is key to understanding collections in Swift.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Ole Begemann: Collections in Swift are very powerful but also very complex. If you want to implement your own custom collection type, you need to understand how the Collection protocol works. And even if all you want to do is use the familiar collection types from the standard library, we think it&rsquo;s worth learning how [&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":[46,71,901],"class_list":["post-15857","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15857","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=15857"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15857\/revisions"}],"predecessor-version":[{"id":15858,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15857\/revisions\/15858"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=15857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=15857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=15857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}