美文网首页
Swift_集合 `swapAt(_:_:)`,交换集合中的值按

Swift_集合 `swapAt(_:_:)`,交换集合中的值按

作者: Eyes_cc | 来源:发表于2020-12-01 07:33 被阅读0次
    /// Exchanges the values at the specified indices of the collection. Both parameters must be valid indices of the collection that are not equal to `endIndex`. Calling `swapAt(_:_:)` with the same index as both `i` and `j` has no effect.
    #按集合的指定索引交换值。两个参数必须是集合的不等于“endIndex”的有效索引。用与i和j相同的索引调用swapAt(_:_:)是没有效果的。
    var numbers = [10, 20, 30, 40, 50]
    numbers.swapAt(0, 1)
    print(numbers)
    // Log  [20, 10, 30, 40, 50]
    

    相关文章

      网友评论

          本文标题:Swift_集合 `swapAt(_:_:)`,交换集合中的值按

          本文链接:https://www.haomeiwen.com/subject/pngrwktx.html