Tom Wayne
Tom Wayne

Reputation: 57

A simple query regarding the difference between two parameters in the function clause

so just a quick question, what is the difference between

Int... 

and

[Int] 

in the function parameters?

For example

func sumOf(numbers: Int...)

and

func calculateStatistics(scores: [Int])

I think I understand [Int] which is asking for an array of Ints. But what does Int... mean in regards to a function parameter?

Thanks Guys.

Upvotes: 1

Views: 13

Answers (1)

Raphael Oliveira
Raphael Oliveira

Reputation: 7841

Please check the variadic parameter section 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.

Upvotes: 1

Related Questions