What this line means in Swift?

前端 未结 3 1984
别跟我提以往
别跟我提以往 2021-01-24 11:10

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

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

}

and there are just this description:

<
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-24 11:53

    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.

提交回复
热议问题