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]
网友评论