Swift_集合 arr.append(100),arr.app

2020-12-22  本文已影响0人  Eyes_cc

    @inlinable public mutating func append(_ newElement: Element)

例如:
var numbers = [1, 2, 3, 4, 5]
numbers.append(100)
print(numbers)  // [1, 2, 3, 4, 5, 100]

    @inlinable public mutating func append<S>(contentsOf newElements: S) where S : Sequence, Self.Element == S.Element

例如:
var numbers = [1, 2, 3, 4, 5]
numbers.append(contentsOf: 10...15)
print(numbers)  // [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]

上一篇下一篇

猜你喜欢

热点阅读