这条线在Swift中意味着什么? [英] What this line means in Swift?

查看:107
本文介绍了这条线在Swift中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在阅读Swift 3书并在那里找到这一行:

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

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

}

并且只有这样的描述:

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

我没有得到那个(数字:Int ...)表示。有人可以解释一下吗?

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

推荐答案

它被称为可变参数,解释了此处


可变参数接受零个或多个指定类型的值。
使用可变参数来指定参数可以是
在调用函数时传递不同数量的输入值。
通过在参数的类型名称后面插入三个句点字符(...)
来写出可变参数。

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.

这篇关于这条线在Swift中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆