swift 函数参数可选
A variadic function is simply a function that accepts 0 or more items of the same type.
可变参数函数只是接受0个或多个相同类型项的函数。
What uses variadic functions?
什么使用可变参数功能?
If you have ever used the print statement then you have used variadic function. If we click into it’s signature, then we get the following
如果您曾经使用过print语句,那么您已经使用了可变参数函数。 如果单击它的签名,则会得到以下内容
public func print(_ items: Any..., separator: String = " ", terminator: String = "\n")
The print function accepts any amount of items that are of type Any. Which allows us to print multiple object by separating them with a comma.
打印功能接受任何类型的任何项目。 这允许我们通过用逗号分隔多个对象来打印它们。
Let’s make our own variadic function
让我们