So I've come to learn that the it
in my foreach loop is immutable - namely I get the error val cannot be reassigned
.
results.forEach{
val subGenreNames = subGenreNames(it.subGenres)
it.subGenres = subGenreNames
}
However I want to be able to update its value after I pass it into my subGenreNames
function.
How can I achieve this?