WWDC21 being less than two weeks away means the first Swift 5.5 beta is almost here, and it comes with a massive set of improvements – async/await,

What's new in Swift 5.5?

submited by
Style Pass
2021-05-28 14:30:03

WWDC21 being less than two weeks away means the first Swift 5.5 beta is almost here, and it comes with a massive set of improvements – async/await, actors, throwing properties, and many more. For the first time it’s probably easier to ask “what isn’t new in Swift 5.5” because so much is changing.

In this article I’m going to walk through each of the changes with code samples, so you can see how each of them work in practice. Before we start, there are two important warnings:

SPONSORED Check out Stream's cross-platform , open-source chat SDK on GitHub – write once and deploy your app with fully featured chat UI on iOS and macOS!

SE-0296 introduces asynchronous (async) functions into Swift, allowing us to run complex asynchronous code almost is if it were synchronous. This is done in two steps: marking async functions with the new async keyword, then calling them using the await keyword, similar to other languages such as C# and JavaScript.

To see how async/await helps the language, it’s helpful to look at how we solved the same problem previously. Completion handlers are commonly used in Swift code to allow us to send back values after a function returns, but they had tricky syntax as you’ll see.

Leave a Comment