{"id":21386,"date":"2018-04-30T17:03:22","date_gmt":"2018-04-30T21:03:22","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=21386"},"modified":"2018-04-30T17:03:22","modified_gmt":"2018-04-30T21:03:22","slug":"reimplementation-of-implicitly-unwrapped-optionals","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/04\/30\/reimplementation-of-implicitly-unwrapped-optionals\/","title":{"rendered":"Reimplementation of Implicitly Unwrapped Optionals"},"content":{"rendered":"<p><a href=\"https:\/\/swift.org\/blog\/iuo\/\">Swift<\/a>:<\/p>\n<blockquote cite=\"https:\/\/swift.org\/blog\/iuo\/\"><p>The new mental model for IOUs is one where you consider <code>!<\/code> to be a synonym for <code>?<\/code> with the addition that it adds a flag on the declaration letting the compiler know that the declared value can be implicitly unwrapped.<\/p><p>[&#8230;]<\/p><p>There are three places where using <code>!<\/code> as part of a type is permitted:<\/p><ol><li>Property declarations<\/li><li><em>Parameters<\/em> in function declarations<\/li><li><em>Return values<\/em> in function declarations<\/li><\/ol><p>[&#8230;]<\/p><p>Because implicitly unwrapped optionals are no longer a type distinct from optionals, they can&rsquo;t be inferred as a type or as any part of a type.<\/p><p>[&#8230;]<\/p><p>Note that the result of <code>AnyObject<\/code> lookup is treated as an optional that is implicitly unwrapped. If you lookup a property that itself is also declared as implicitly unwrapped, the expression now has two levels of implicit unwrapping[&#8230;] <code>if let<\/code> and <code>guard let<\/code> only unwrap a single level of optionality.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Swift: The new mental model for IOUs is one where you consider ! to be a synonym for ? with the addition that it adds a flag on the declaration letting the compiler know that the declared value can be implicitly unwrapped.[&#8230;]There are three places where using ! as part of a type is permitted:Property [&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":"2018-04-30T21:03:24Z","apple_news_api_id":"11003216-6640-437a-9382-7603a000c0a3","apple_news_api_modified_at":"2018-04-30T21:03:24Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AEQAyFmZAQ3qTgnYDoADAow","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":[255,46,71,901],"class_list":["post-21386","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-compiler","tag-languagedesign","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21386","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=21386"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21386\/revisions"}],"predecessor-version":[{"id":21387,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21386\/revisions\/21387"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=21386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=21386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=21386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}