结构
Repeated
一个集合,其元素都是相同的。
声明
@frozen struct Repeated<Element>
概述
您可以通过调用repeatElement(_:count:)
函数来创建Repeated
集合的实例。以下示例创建一个包含重复五次的名称 “Humperdinck” 的集合:
let repeatedName = repeatElement("Humperdinck", count: 5)
for name in repeatedName {
print(name)
}
// "Humperdinck"
// "Humperdinck"
// "Humperdinck"
// "Humperdinck"
// "Humperdinck"
可用版本
iOS 8.0+, iPadOS 8.0+, macOS 10.10+, Mac Catalyst 13.0+, tvOS 9.0+, watchOS 2.0+
相关用法
- Swift Repeated dropFirst(_:)用法及代码示例
- Swift Repeated isEmpty用法及代码示例
- Swift Repeated reversed()用法及代码示例
- Swift Repeated joined()用法及代码示例
- Swift Repeated firstIndex(where:)用法及代码示例
- Swift Repeated max(by:)用法及代码示例
- Swift Repeated sorted(by:)用法及代码示例
- Swift Repeated map(_:)用法及代码示例
- Swift Repeated split(separator:maxSplits:omittingEmptySubsequences:)用法及代码示例
- Swift Repeated enumerated()用法及代码示例
- Swift Repeated suffix(from:)用法及代码示例
- Swift Repeated first用法及代码示例
- Swift Repeated allSatisfy(_:)用法及代码示例
- Swift Repeated randomElement(using:)用法及代码示例
- Swift Repeated starts(with:)用法及代码示例
- Swift Repeated prefix(_:)用法及代码示例
- Swift Repeated min()用法及代码示例
- Swift Repeated shuffled()用法及代码示例
- Swift Repeated reduce(into:_:)用法及代码示例
- Swift Repeated compactMap(_:)用法及代码示例
- Swift Repeated index(_:offsetBy:limitedBy:)用法及代码示例
- Swift Repeated last用法及代码示例
- Swift Repeated last(where:)用法及代码示例
- Swift Repeated firstIndex(of:)用法及代码示例
- Swift Repeated shuffled(using:)用法及代码示例
注:本文由纯净天空筛选整理自apple.com大神的英文原创作品 Repeated。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。