/// 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]
网友评论