Home Swift 5.3 notes
Post
Cancel

Swift 5.3 notes

SE-2076 Multi-pattern catch clause

1
2
3
do {
    //...
} catch MyError.code1, MyError.code2 {}

SE-2079 Multiple trailing closure

No need for small curly braces anymore.

1
2
3
4
5
6
7
Button {
    //...
} label {
    // ...
} action {
    // ...
}

SE-2066 Comparable conformance for enum

Now we can compare enum case with > or < or etc.

1
2
3
4
5
6
enum Size {
    case small
    case large
}

if Size.small < Size.large {}

SE-2081 @main attribute

Type based program entry point

1
2
3
4
@main 
struct MyApp {
    static main() {}
}

It requires a static main function.

SE-0267 where clause inside a generic type or extension

1
2
3
4
struct Foo<Element> {}
extension Foo {
    func jump() -> Element where Element: Comparable {}
}

SE-0280 enum cases as protocol matching witness

1
2
3
4
5
6
7
protocol Foo {
    var name: String
}

enum Zoo: Foo {
    case name
}

References

This post is licensed under CC BY 4.0 by the author.