{"id":14909,"date":"2016-06-21T14:48:11","date_gmt":"2016-06-21T18:48:11","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=14909"},"modified":"2016-06-21T14:48:11","modified_gmt":"2016-06-21T18:48:11","slug":"increased-safety-in-swift-3","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/06\/21\/increased-safety-in-swift-3\/","title":{"rendered":"Increased Safety in Swift 3"},"content":{"rendered":"<p><a href=\"https:\/\/www.bignerdranch.com\/blog\/wwdc-2016-increased-safety-in-swift-3\/\">Matt Mathias<\/a>:<\/p>\n<blockquote cite=\"https:\/\/www.bignerdranch.com\/blog\/wwdc-2016-increased-safety-in-swift-3\/\">\n<p>Things are different with Swift 3.0. The <code>!<\/code> in <code>init!<\/code> indicates that the initialization process can fail, and if it doesn&rsquo;t, that the resulting instance may be forced (i.e., implicitly unwrapped). Unlike in Swift 2.x, instances resulting from <code>init!<\/code> are <code>Optional<\/code>s and not <code>ImplicitlyUnwrappedOptional<\/code>s. That means you will have to employ optional binding or chaining to access the underlying value.<\/p>\n<p>[&#8230;]<\/p>\n<p>We never explicitly declared that <code>nilPerson<\/code> should be an <code>ImplicitlyUnwrappedOptional<\/code>. And it&rsquo;s not great that the compiler inferred unsafe type information.<\/p>\n<p>Swift 3.0 solves this problem by treating <code>ImplicitlyUnwrappedOptional<\/code>s as <code>Optional<\/code> unless we explicitly declare that we want an <code>ImplicitlyUnwrappedOptional<\/code>.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Matt Mathias: Things are different with Swift 3.0. The ! in init! indicates that the initialization process can fail, and if it doesn&rsquo;t, that the resulting instance may be forced (i.e., implicitly unwrapped). Unlike in Swift 2.x, instances resulting from init! are Optionals and not ImplicitlyUnwrappedOptionals. That means you will have to employ optional binding [&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-14909","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\/14909","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=14909"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/14909\/revisions"}],"predecessor-version":[{"id":14910,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/14909\/revisions\/14910"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=14909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=14909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=14909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}