Variadic Arguments in Functions — Swift
Published in
1 min readApr 25, 2020
In order to simplify your code, you can make use of custom functions that take in a varying list of arguments. This concept is known as a variadic argument in Swift.
Let's say you have the following screen:
You have following subviews to add in UIViewController’s view. Here is how you can achieve that via Variadic Arguments:
Similarly, you can create any function with Variadic Arguments as for integers:
This way you can write clean and simple code. Share if you like :)