Arrays 从Swift中的函数返回数组
我无法从Swift中的函数调用返回数组 脚本现在有点长,也有点复杂,但这基本上是函数内输出的结果:Arrays 从Swift中的函数返回数组,arrays,swift,function,Arrays,Swift,Function,我无法从Swift中的函数调用返回数组 脚本现在有点长,也有点复杂,但这基本上是函数内输出的结果: func getRecentUpdates() { var updates = [("test", "hello"),("nice", "one")] println(updates) return updates } println在控制台中显示数组,但使用返回,一个错误表示NSArray()不能转换为(),这应该可以工作
func getRecentUpdates()
{
var updates = [("test", "hello"),("nice", "one")]
println(updates)
return updates
}
println在控制台中显示数组,但使用返回
,一个错误表示NSArray()不能转换为()
,这应该可以工作:
func getRecentUpdates()->[(String,String)]
{
let updates = [("test", "hello"),("nice", "one")]
return updates
}
斯佩克特对swift 4的更新:
func getRecentUpdates()-> Array<[String]>{
let updates = [("test", "hello"),("nice", "one")]
return updates
}
func getRecentUpdates()->数组{
让更新=[(“测试”,“你好”),(“不错”,“一个”)]
返回更新
}
hi user。。你做这件事<代码>->指示函数的返回值@米卡:你说得对,我只是想复制他们拥有的东西,稍微修改一下,这样就行了。我会调整我的答案