``` for (j in 0 until pdfReader.numberO...
# getting-started
o
Copy code
for (j in 0 until pdfReader.numberOfPages) {
                extractedText += PdfTextExtractor.getTextFromPage(pdfReader, j + 1)

                technologies.forEach { (key, values) ->
                    values.map {
                        if (extractedText.contains(it, ignoreCase = true)
                            || extractedText.contains("${it}s", ignoreCase = true)
                        ) {
                            occurrences[key] = occurrences.getOrDefault(key, 0) + 1
                        }
                    }
                }
            }

            println(occurrences)
            val person = extractedText.split(" ")[0].trim { it == ',' }
            results[person] = occurrences
I would like to clear
occurrences
after I’m done with it so that I can load it again with new values after I insert it into
results[person]
but doing that is causing it to store an empty map into `results[person]`…
setting occurrnces to a new map solves this, but I want to clear it..
m
Everything is references, so any changes you make to the object will change all references to it including what is in results. So you need two instances. You can either replace occurrences with a new map or copy (
occurrences.toMap()
) the map when you add it to results.
o
yes suspected so
but didn’t think it was that serious 😄
thank you