Doe Doe - 1 year ago 69
Swift Question

What this line means in Swift?

I'm now reading Swift 3 book and found this line there:

func sumOf(numbers: Int...) -> Int {


and there are just this description:

Functions can also take a variable number of arguments, collecting them into an array.

I did not get what that
(numbers: Int...)
means. Can anyone explain me, please?

Answer Source

It's called variadic arguments, explained here.

A variadic parameter accepts zero or more values of a specified type. You use a variadic parameter to specify that the parameter can be passed a varying number of input values when the function is called. Write variadic parameters by inserting three period characters (...) after the parameter’s type name.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download