I have this code:
val products = List() def loadProducts(report: (Asset, Party, AssetModel, Location, VendingMachineReading)) = { report match { case (asset, party, assetModel, location, reading) => EvadtsParser.parseEvadts(reading.evadts, result) (result.toMap).map(product => ReportData( customer = party.name, location = location.description, asset = asset.`type`, category = "", product = product._1, counter = product._2, usage = 0, period = "to be defined")).toList } } results.foreach(result => products ::: loadProducts(result)) println(products) Can you please tell me what I am doing wrong because products list is empty? If I println products inside loadProducts method, products is not empty. Is the concatenation I am doing wrong?
PS: I am a scala beginner.
:::yields a new list instead of mutating the one you already have in place.