package com.example.puzzles.lambda.loop data class Product(val name: String, val cost: Int) val shoppingList = listOf( Product("Eggs", cost = 10), Product("Flour", cost = 10), Product("Sugar", cost = 10), ) fun main() { var moneySpent = 0 val purchasedItems = mutableListOf() shoppingList.forEach { product -> purchasedItems += product.name moneySpent += product.cost if (moneySpent >= 20) { return@forEach } } println("Spent a total of $moneySpent to buy $purchasedItems") }