0

I want to change my array of double to array of string with this code:

var arrayOfDouble: [[Double]] = [[..]]

func change(_ doubles: [[Double]]) -> [[String]]{
    var result:[[String]] = [[]]
    
    for i in 0..<doubles.count{
        for j in 0..<doubles[i].count{
            result[i][j] = String(doubles[i][j])
        }
    }

    return result
}

var lll:[[String]] = change(arrayOfDouble)

print(lll)

But the app crashed with a warning: Thread 1: Fatal error: Index out of range.

I tried to test the function in playground and it resulting an error:

error: Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x18bd55e10).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

How to fix this problem?

0 Answers0