如何使用下划线参数
func test(currentName name: String, _: Int) {
print("aa\(name) abc");
//how to use _ parameter?
}
test(currentName:"aa", 3)
_
意味着当您调用test
函数时,您不必在第二个参数之前编写文本test(currentName:"aa", 3)
如果您这样声明函数:
func test(currentName name: String, secondParameter: Int) {
print("aa\(name) abc");
//how to use _ parameter?
}
然后在调用test
函数时,必须像这样调用:
test(currentName:"aa", secondParameter: 3)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句