{"id":10143,"date":"2014-11-25T00:50:43","date_gmt":"2014-11-25T05:50:43","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=10143"},"modified":"2014-11-25T00:50:43","modified_gmt":"2014-11-25T05:50:43","slug":"a-swift-corner-case","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/11\/25\/a-swift-corner-case\/","title":{"rendered":"A Swift Corner Case"},"content":{"rendered":"<p><a href=\"http:\/\/pado.name\/blog\/2014\/11\/swift-corner-case\">Geoff Pado<\/a>:<\/p>\n<blockquote cite=\"http:\/\/pado.name\/blog\/2014\/11\/swift-corner-case\"><p>Any call to a method or property that uses optional chaining will return the same type as it normally does, but wrapped in a optional. Which makes sense&mdash;any broken link in the chain will cause the whole thing to return <code>nil<\/code>. This is true <em>even<\/em> for methods that return <code>Void<\/code>. Chained calls will return <code>Void?<\/code>.<\/p>\n<p>[&#8230;]<\/p>\n<p>Because of the combination of optional chaining and implicit return, we suddenly were left with a closure that was automatically returning something of type <code>Void?<\/code>, which clashed with <code>addOperationWithBlock()<\/code>&rsquo;s expectation of <code>Void<\/code>.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Geoff Pado: Any call to a method or property that uses optional chaining will return the same type as it normally does, but wrapped in a optional. Which makes sense&mdash;any broken link in the chain will cause the whole thing to return nil. This is true even for methods that return Void. Chained calls will [&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-10143","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\/10143","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=10143"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10143\/revisions"}],"predecessor-version":[{"id":10144,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/10143\/revisions\/10144"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=10143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=10143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=10143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}