Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift convert Range<Int> to [Int]

You need to create an Array<Int> using the Range<Int> rather than casting it.

let intArray: [Int] = Array(min...max)

Put the Range in the init.

let intArray = [Int](min...max)

I figured it out:

let intArray = [Int](min...max)

Giving credit to someone else.


do:

let intArray = Array(min...max)

This should work because Array has an initializer taking a SequenceType and Range conforms to SequenceType.