In a simple Swift enumeration like this:
for (index, value) in enumerate(array) {
let indexValue = idx as NSNumber
let double = indexValue.doubleValue
.... }
is there an easier way to convert the 'index' value to a double?
Yes there is:
for (index, value) in enumerate(array) {
let doubleVal = Double(index)
}
The number types in Swift generally have an init method that takes any of the other number types.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.