swift convert Range to [Int]

前端 未结 8 595
感动是毒
感动是毒 2021-02-03 16:51

how to convert Range to Array

I tried:

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

get error Range is

8条回答
  •  后悔当初
    2021-02-03 16:54

    do:

    let intArray = Array(min...max)
    

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

提交回复
热议问题