swifter-tips / Public-Issues

Public issues for Swifter-tips book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

下标,@UIAPPLICATIONMAIN,多元组

Abysssea opened this issue · comments

下标:

extension Array {

subscript(input: [Int]) -> Slice<T> {

    get {
        var result = Slice<T>()
        for i in input {
            assert(i < self.count, "Index out of range")
            result.append(self[i])
        }
        return result
    }

    set {
        for (index,i) in enumerate(input) {
            assert(i < self.count, "Index out of range")
            self[i] = newValue[index]
        }
    }
}

}

实例代码中,Slice 变成了 ArraySlice,T变成了Element,set里的enumerate(input)换成了input.enumerate()

@UIApplicationMain

UIApplicationMain(C_ARGC, C_ARGV, nil, NSStringFromClass(AppDelegate))

里面的C_ARGC,C_ARGV参数换成了Process.argc和 Process.unsafeArgv。

多元组:
现在不能这样写了
var a: Int = 4
a.0.0.0.0
提示Value of type of "Int" has no member "0"

看了第二版,发现已经改完了,网页版什么时候更新啊?

网页版可能不太有精力去更新了 T-T