I have problem with ConcurrentModificationException. Here's my part of the code :
var deltaSum = 0
arrDeltaBrainWaves.map {
value -> deltaSum += value
}
To be clear - I know why this error appears :) The problem is - I have no idea what's the solution ? Do I really need to create new temp list and put values there ? It just doesnt make sense :) Any better options, please ?
EDIT:
I changed the code to below :
var deltaSum = 0
with(arrDeltaBrainWaves.iterator()) {
forEach {
deltaSum += it
}
}
avgDelta = deltaSum / arrDeltaBrainWaves.size
But problem still exists.
you need to use the Iterators
example:
this will avoid ConcurrentModificationExceptions