我正在學習Swift。下面是我的代碼:具有相關值的Swift枚舉,在調用「缺少參數標籤」數組「
enum MyTest
{
case Point(Int, Int)
case What(String)
case GiveMeFunc((array: Int...) -> Int)
}
var p1 = MyTest.Point(2, 2)
var p2 = MyTest.Point(3, 3)
var s1 = MyTest.What("Haha...")
var s2 = MyTest.What("Heihei...")
var f1 = MyTest.GiveMeFunc({(array: Int...) -> Int in return 8})
var f2 = MyTest.GiveMeFunc({(array: Int...) -> Int in return 9})
switch p1 {
case .What(let string):
println(string)
case .GiveMeFunc(let f):
println(f(1, 2, 4, 3))
case .Point(let a, let b):
println("a: \(a) b: \(b)")
}
當我運行它,我得到了
missing argument label 'array' in call.
這個錯誤來自:
println(f(1, 2, 4, 3))`
如何修正這個錯誤?
@MaximShoustin看的情況下 – Arbitur