{"id":10825,"date":"2015-03-13T21:03:18","date_gmt":"2015-03-14T01:03:18","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10825"},"modified":"2015-03-13T21:03:18","modified_gmt":"2015-03-14T01:03:18","slug":"flatmap-and-swift-1-2-betas-2-and-3","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2015\/03\/13\/flatmap-and-swift-1-2-betas-2-and-3\/","title":{"rendered":"flatMap and Swift 1.2 Betas 2 and 3"},"content":{"rendered":"<p><a href=\"http:\/\/airspeedvelocity.net\/2015\/03\/13\/changes-to-the-swift-standard-library-in-1-2-betas-2-and-3\/\">Airspeed Velocity<\/a>:<\/p>\n<blockquote cite=\"http:\/\/airspeedvelocity.net\/2015\/03\/13\/changes-to-the-swift-standard-library-in-1-2-betas-2-and-3\/\">\n<p>And at this point, hopefully it&rsquo;s clear that <code>flatMap<\/code> and optional chaining do very similar things.  Optional chaining essentially <em>is<\/em> a compact version of <code>flatMap<\/code> that only works on methods.  When you want the same functionality as optional chaining, but instead with a function you need to pass the optional value <em>into<\/em>  (like with <code>find<\/code>) instead of calling a method on that value, you need <code>flatMap<\/code>.<\/p>\n<p>That&rsquo;s not all <code>flatMap<\/code> does &#8211; it&rsquo;s also a method on arrays (think of a mapping function that turns elements into arrays of elements), and there&rsquo;s a generic free function version that works on sequences and collections.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Airspeed Velocity: And at this point, hopefully it&rsquo;s clear that flatMap and optional chaining do very similar things. Optional chaining essentially is a compact version of flatMap that only works on methods. When you want the same functionality as optional chaining, but instead with a function you need to pass the optional value into (like [&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-10825","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\/10825","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=10825"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10825\/revisions"}],"predecessor-version":[{"id":10826,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10825\/revisions\/10826"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}