LoginSignup
16
14

More than 5 years have passed since last update.

SwiftでRangeからArrayを取得する

Last updated at Posted at 2014-06-24

(1..100).toArray()みたいな感じでできれば良かったんですが、このようなメソッドは用意されておらず。

しかたないのでキャストします。

let array = (Array<Int>)(1...100)

//あとは自由にArrayとして操作する
println array.map{ $0 * 10 }
16
14
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14