美文网首页
Swift_数组 arr.append(contentsOf:

Swift_数组 arr.append(contentsOf:

作者: Eyes_cc | 来源:发表于2020-11-30 14:30 被阅读0次

Swift_数组 arr.append(contentsOf: stride(from: 20, to: 100, by: 10)),集合添加一个Sequence生成新集合

// stride(from: 20, to: 100, by: 10)
// :Returns a sequence from a starting value to, but not including an end value, stepping by the specified amount.
var arr = [Int]()
arr.append(contentsOf: stride(from: 20, to: 100, by: 10))
print(arr)
// 返回从20到100,间隔10的新集合,不包括100
// Log   [20, 30, 40, 50, 60, 70, 80, 90]

Swift_数组 arr.append(contentsOf: stride(from: 20, through: 100, by: 10)),集合添加一个Sequence生成新集合

// stride(from: 20, through: 100, by: 10)
// :Returns a sequence from a starting value toward, and possibly including an end value, stepping by the specified amount.
var arr = [Int]()
arr.append(contentsOf: stride(from: 20, through: 100, by: 10))
print(arr)
// 返回从20到100,间隔10的新集合
// Log   [20, 30, 40, 50, 60, 70, 80, 90, 100]

相关文章

网友评论

      本文标题:Swift_数组 arr.append(contentsOf:

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