I have this code that keeps giving me a "Val cannot be reassigned" error but I can't seem to change the variable to a var instead of val. I simply want to be able to set a string value to my cell reference so I can access the values later like this myStringsArrayList.add(deviceData.cellOne).
Here is my code:
val cells = listOf(
            deviceData.cellOne,
            deviceData.cellTwo,
            deviceData.cellThree,
            deviceData.cellFour,
            deviceData.cellFive,
            deviceData.cellSix,
            deviceData.cellSeven,
            deviceData.cellEight,
            deviceData.cellNine,
            deviceData.cellTen,
            deviceData.cellEleven,
            deviceData.cellTwelve,
            deviceData.cellThirteen,
            deviceData.cellFourteen
        )
        for ((i, cell) in cells.withIndex()) {
            val value = data[2 + i].toDouble() / 100 + 3.52
            val cellNumberString = (i + 1).toString()
            val formattedString = "Cell $cellNumberString: %.2fV".format(value)
            cell = formattedString // THIS IS WHERE THE PROBLEM IS (cell is a val)
        }
Does anyone know how I can get around this and achieve the functionality that I want?
I tried using a listIterator() but it hasn't seemed to work the way that I want it to.
Here is my attempt with the listIterator():
val cells = mutableListOf(
            deviceData.cellOne,
            deviceData.cellTwo,
            deviceData.cellThree,
            deviceData.cellFour,
            deviceData.cellFive,
            deviceData.cellSix,
            deviceData.cellSeven,
            deviceData.cellEight,
            deviceData.cellNine,
            deviceData.cellTen,
            deviceData.cellEleven,
            deviceData.cellTwelve,
            deviceData.cellThirteen,
            deviceData.cellFourteen)
        val iterate = cells.listIterator()
        while (iterate.hasNext()) {
            var cell = iterate.next()
            val value = data[2 + iterate.nextIndex()].toDouble() / 100 + 3.52
            val cellNumberString = (iterate.nextIndex() + 1).toString()
            val formattedString = "Cell $cellNumberString: %.2fV".format(value)
            cell = formattedString
        }