美文网首页
Swift_集合 初始化 let arr = Array(rep

Swift_集合 初始化 let arr = Array(rep

作者: Eyes_cc | 来源:发表于2020-12-21 15:39 被阅读0次

创建一个包含指定数量重复值的集合。

/// 创建一个包含指定数量重复值的新集合。
///
/// 下面是一个创建数组的例子,它用包含字母*Z*的五个字符串初始化。
///
/// - Parameters:
///   - repeatedValue: 要重复的元素
///   - count:         重复次数。' count '必须为零或更大。
    @inlinable public init(repeating repeatedValue: Element, count: Int)

let fiveZs = Array(repeating: "Z", count: 5)
print(fiveZs)  // ["Z", "Z", "Z", "Z", "Z"]

相关文章

网友评论

      本文标题:Swift_集合 初始化 let arr = Array(rep

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