修改CollectionType的最佳方法

时间:2016-07-01 14:10:43

标签: ios swift collections

我正在扩展CollectionType,希望能够轻松修改集合类型。

您不能myCollection[Index] = whatever

修改内容的最佳方式是什么?

例如

extension CollectionType {
    func doSomething() -> Self{
        var result = self
        result[self.startIndex] = result[self.endIndex]
        return result
    }
}

0 个答案:

没有答案