【发布时间】:2017-08-20 00:25:36
【问题描述】:
struct Bar
{
var one:[Int] = []
var two:[Int] = []
var tri:[Int] = []
}
class foo
{
var bar = Bar()
func setupBar()
{
bar.one = [1]
bar.two = [2,2]
bar.tri = [3,3,3]
}
//bars are updated here
func updateBars()
{
updateBar(bar.one, bar.two) //...here...
updateBar(bar.two, bar.tri) //...here...
//etc...
}
//Bar1 should be concatenated with Bar2, and thus Bar1 will be updated.
func updateBar(_bar1:[Int], _bar2:[Int]) //...here...
{
}
在上面的例子中,updateBar方法的参数在定义和调用中的正确语法是什么?
我尝试使用 inout,但也没有用。
【问题讨论】:
标签: swift class methods parameters