操作符
+=(_:
+=(_:_:)
將序列的元素附加到 range-replaceable 集合。
聲明
static func += <Other>(lhs: inout Self, rhs: Other) where Other : Sequence, Self.Element == Other.Element
參數
lhs
要附加到的數組。
rhs
集合或有限序列。
詳述
使用此運算符將序列的元素附加到具有相同 Element
類型的 range-replaceable 集合的末尾。此示例將 Range<Int>
實例的元素附加到整數數組。
var numbers = [1, 2, 3, 4, 5]
numbers += 10...15
print(numbers)
// Prints "[1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15]"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相關用法
- Swift Slice +(_:_:)用法及代碼示例
- Swift Slice endIndex用法及代碼示例
- Swift Slice reduce(into:_:)用法及代碼示例
- Swift Slice contains(_:)用法及代碼示例
- Swift Slice removeAll(where:)用法及代碼示例
- Swift Slice lastIndex(where:)用法及代碼示例
- Swift Slice removeFirst()用法及代碼示例
- Swift Slice suffix(_:)用法及代碼示例
- Swift Slice starts(with:)用法及代碼示例
- Swift Slice reduce(_:_:)用法及代碼示例
- Swift Slice insert(_:at:)用法及代碼示例
- Swift Slice isEmpty用法及代碼示例
- Swift Slice sorted()用法及代碼示例
- Swift Slice split(separator:maxSplits:omittingEmptySubsequences:)用法及代碼示例
- Swift Slice dropLast(_:)用法及代碼示例
- Swift Slice sorted(by:)用法及代碼示例
- Swift Slice partition(by:)用法及代碼示例
- Swift Slice last(where:)用法及代碼示例
- Swift Slice joined(separator:)用法及代碼示例
- Swift Slice base用法及代碼示例
- Swift Slice enumerated()用法及代碼示例
- Swift Slice insert(contentsOf:at:)用法及代碼示例
- Swift Slice prefix(upTo:)用法及代碼示例
- Swift Slice shuffle(using:)用法及代碼示例
- Swift Slice removeSubrange(_:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Slice +=(_:_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。