-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Swift5.9.swift
37 lines (30 loc) · 1016 Bytes
/
Swift5.9.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import SwiftUI
struct ContentView: View {
var body: some View {
TabBarView()
}
}
#Preview {
ContentView()
}
// https://www.swift.org/blog/swift-5.9-released/
// Macros
let _: Font = #fontLiteral(name: "SF Mono", size: 14, weight: .regular)
// Parameter packs
func all<each Wrapped>(_ optional: repeat (each Wrapped)?) -> (repeat each Wrapped)?
func useAll() {
if let (int, double, string, bool) = all(optionalInt, optionalDouble, optionalString, optionalBool) {
print(int, double, string, bool)
}
else {
print("got a nil")
}
}
// return value on if/else if/else
statusBar.text = if !hasConnection { "Disconnected" }
else if let error = lastError { error.localizedDescription }
else { "Ready" }
// https://docs.swift.org/swift-book/documentation/the-swift-programming-language/macros/
@attached(member)
@attached(conformance)
public macro OptionSet<RawType>() = #externalMacro(module: "SwiftMacros", type: "OptionSetMacro")