<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Swift 5.9 - 标签 - 宋明的博客</title><link>https://apolla.cc/tags/swift-5.9/</link><description>宋明的博客</description><generator>Hugo 0.170.0 &amp; FixIt v1.0.0-rc.5-mwimukpl</generator><language>zh-cn</language><lastBuildDate>Fri, 19 Apr 2024 15:20:06 +0800</lastBuildDate><atom:link href="https://apolla.cc/tags/swift-5.9/index.xml" rel="self" type="application/rss+xml"/><item><title>5 Swift 5.9 新特性</title><link>https://apolla.cc/posts/5-swift-5.9-%E6%96%B0%E7%89%B9%E6%80%A7/</link><pubDate>Fri, 19 Apr 2024 15:20:06 +0800</pubDate><guid>https://apolla.cc/posts/5-swift-5.9-%E6%96%B0%E7%89%B9%E6%80%A7/</guid><category domain="https://apolla.cc/categories/swiftui/">SwiftUI</category><description>&lt;br&gt;&#10;&lt;blockquote&gt;&#10;&lt;p&gt;注：Swift 5.9 目前并未正式发布，本文会在正式发布后再次更新。&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;h1 class="heading-element" id="if-和-switch-表达式se-0380"&gt;&lt;span&gt;if 和 switch 表达式（&lt;a href="https://github.com/apple/swift-evolution/blob/main/proposals/0380-if-switch-expressions.md" target="_blank" rel="external nofollow noopener noreferrer"&gt;SE-0380&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;）&lt;/span&gt;&#10; &lt;a href="#if-%e5%92%8c-switch-%e8%a1%a8%e8%be%be%e5%bc%8fse-0380" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;pre&gt;&lt;code&gt;let s1 = if Bool.random() { &amp;#34;YES&amp;#34; } else { &amp;#34;NO&amp;#34; }&#10;&#10;let s2 = switch Bool.random() {&#10;case true: &amp;#34;YES&amp;#34;&#10;case false: &amp;#34;NO&amp;#34;&#10;}&lt;/code&gt;&lt;/pre&gt;&lt;h1 class="heading-element" id="值和类型参数包se-0393"&gt;&lt;span&gt;值和类型参数包（&lt;a href="https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md" target="_blank" rel="external nofollow noopener noreferrer"&gt;SE-0393&lt;i class="fa-solid fa-external-link-alt fa-xs ms-1 text-secondary" aria-hidden="true"&gt;&lt;/i&gt;&lt;/a&gt;）&lt;/span&gt;&#10; &lt;a href="#%e5%80%bc%e5%92%8c%e7%b1%bb%e5%9e%8b%e5%8f%82%e6%95%b0%e5%8c%85se-0393" class="heading-mark"&gt;&lt;svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"&gt;&lt;path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"&gt;&lt;/path&gt;&lt;/svg&gt;&lt;/a&gt;&#10;&lt;/h1&gt;&lt;p&gt;值和类型参数，实现了对不同类型的值和类型的抽象化，这是在 Swift 中实现可变泛型的第一步。&lt;/p&gt;</description></item></channel></rss>