有没有一种方法,即时生成充满斯威夫特值的范围数组? [英] Is there a way to instantly generate an array filled with a range of values in Swift?
本文介绍了有没有一种方法,即时生成充满斯威夫特值的范围数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,在python我可以说线沿线的东西。
For example, in python I could say something along the lines of
arr = range(0,30)
和得到一个数组的元素表示。
我怀疑,类似的东西有可能在斯威夫特下标,但淘文档和苹果的iBook后,我找不到产生所述阵列的电池包料的解决方案。
and get an array with said elements. I suspect that something similar might be possible with a subscript in Swift, but after scouring the documentation and Apple's iBook I can't find a "batteries-included" solution for generating said array.
这是不是我不得不手动编写code代表,或者是有它pre-写的方法?
Is this something I'd have to write the code manually for, or is there a pre-written method for it?
推荐答案
您可以用这样一个范围内创建一个数组:
You can create an array with a range like this:
var values = Array(0...100)
这会给你的数组[0,...,100]
这篇关于有没有一种方法,即时生成充满斯威夫特值的范围数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文