{"id":2370,"date":"2022-12-26T00:27:24","date_gmt":"2022-12-25T21:27:24","guid":{"rendered":"https:\/\/sezeromer.com\/?p=2370"},"modified":"2023-03-04T14:46:54","modified_gmt":"2023-03-04T11:46:54","slug":"swift-5-7-yenilikler","status":"publish","type":"post","link":"https:\/\/sezeromer.com\/en\/swift-5-7-yenilikler\/","title":{"rendered":"Swift 5.7"},"content":{"rendered":"<p>Hello friends, in this article, we will talk about the innovations that come with Swift 5.7. With the 5.7 version, many new developments were made. You can review all the changes <a href=\"https:\/\/www.swift.org\/blog\/swift-5.7-released\/\">here<\/a>. Here I will share the most notable features.<\/p>\r\n<h3>If Let De\u011fi\u015fikli\u011fi<\/h3>\r\n<p>There are many ways to make an Optional variable unoptional. One of them is <strong>if let<\/strong>. You can make an optinal variable unoptional with if let as follows.<\/p>\r\n<div class=\"wp-block-codemirror-blocks code-block\">\r\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">import UIKit\r\n\r\nvar animal: String? = \"Dog\"\r\n\r\nif let animal = animal {\r\n    print(animal)\r\n}\r\n<\/pre>\r\n<\/div>\r\n<p>Now we don&#8217;t need to equate the variable we created with if let to the optional variable instead. You can use as below.<\/p>\r\n<p>&nbsp;<\/p>\r\n<div class=\"wp-block-codemirror-blocks code-block \">\r\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">import UIKit\r\n\r\nvar animal: String? = \"Dog\"\r\n\r\nif let animal {\r\n    print(animal)\r\n}\r\n<\/pre>\r\n<\/div>\r\n<p>More details can be found <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/main\/proposals\/0345-if-let-shorthand.md\">here<\/a>.<\/p>\r\n<h3>Multi Statement Closure Parameter<\/h3>\r\n<p>With this change, we don&#8217;t need to specify the parameter to return from a closure. As you can see in the example below, I can run it without specifying what type to return.<\/p>\r\n<div class=\"wp-block-codemirror-blocks code-block \">\r\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">import UIKit\r\n\r\nlet numbers = [54, 90, 110, 72]\r\n\r\nlet values = numbers.map { number in\r\n    return \"\\(number)\"\r\n}\r\n<\/pre>\r\n<\/div>\r\n<p>Before Swift 5.7, I had to specify this type as follows.<\/p>\r\n<div class=\"wp-block-codemirror-blocks code-block \">\r\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;swift&quot;,&quot;mime&quot;:&quot;text\/x-swift&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:true,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">import UIKit\r\n\r\nlet numbers = [54, 90, 110, 72]\r\n\r\nlet values = numbers.map { number -&gt; String in\r\n    return \"\\(number)\"\r\n}<\/pre>\r\n<\/div>\r\n<p>More details can be found <a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/main\/proposals\/0326-extending-multi-statement-closure-inference.md\">here<\/a>.<\/p>\r\n<p>You can find more articles with Swift <a href=\"https:\/\/sezeromer.com\/swift\/\">here<\/a>. If you have any questions, you can contact me by sending an e-mail or comment.\u00a0<\/p>\r\n\r\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Hello friends, in this article, we will talk about the innovations that come with Swift 5.7. With the 5.7 version, many new developments were made. You can review all the changes here. Here I will share the most notable features. If Let De\u011fi\u015fikli\u011fi There are many ways to make an Optional variable unoptional. One of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1706,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[327,706],"tags":[956,348,957,354,328,707],"class_list":["post-2370","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swift","category-swiftui","tag-5-7","tag-if","tag-if-let","tag-let","tag-swift","tag-swiftui"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2370"}],"collection":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/comments?post=2370"}],"version-history":[{"count":7,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2370\/revisions"}],"predecessor-version":[{"id":2691,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/posts\/2370\/revisions\/2691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media\/1706"}],"wp:attachment":[{"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/media?parent=2370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/categories?post=2370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sezeromer.com\/en\/wp-json\/wp\/v2\/tags?post=2370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}