Member-only story
What’s New in Swift 5.4?
Multiple variadic parameters, extended implicit member syntax, result builders, and more

Swift 5.4 brings us a lot which is why I like it. In this article, we learn what is new in Swift 5.4.
Note: You can download this article’s example project and sources on GitHub. To open and edit these files, you have to use Xcode 12.5 beta. You can download Xcode 12.5 beta here. Instead of downloading Xcode 12.5 beta, you can download Swift 5.4 directly here.
The Most Important Improvement😄
As anyone who has created an Xcode project or playground file before will know, when you create a new playground or a new Xcode project, the following value will be written on this project:
var str = "Hello, playground"
The name of this value has changed with Swift 5.4 as follows:
var greeting = "Hello, playground"
Yes, I think this is the interesting and funny part of Swift 5.4.
Now we can look at improvements that really work!
Multiple Variadic Parameters
In Swift 5.4, we can use multiple variadic parameters on functions, methods, subscripts, and initializers. Before Swift 5.4, we had just one variadic parameter, like the code below:
func method(singleVariadicParameter: String) {}
Now, we can write multiple variadic parameters like the code below:
func method(multipleVariadicParameter: String..., secondMultipleVariadicParameter: String...) {}
We can call the function we wrote above, but of course, we can only write one String
element if we want. Here’s the code:
method(multipleVariadicParameter: "Can", "Steve", "Bill", secondmultipleVariadicParameter: "Tim", "Craig")
Multiple variadic parameters work just like arrays. Of course, when calling a value in a parameter, it is necessary to check beforehand if that value exists or not; otherwise, it will be wrong and crash. Here’s the code:
func chooseSecondPerson(persons: String...) -> String {
let index = 1
if persons.count >…